Quantcast
Channel: How to add in a list in racket - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by alinsoar for How to add in a list in racket

$
0
0
(define (sum l)  (foldl (lambda(x acc) (+ acc (if (pair? x) (sum x) x)))  0  l))> (sum '(1 2 3 (1 2 3)))12> (sum '(1 2 3))6

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>