Fandom

Distributed Interactive Functional Fiction Programming

Sum list of integers

13pages on
this wiki
Add New Page
Talk0 Share

Main_Page/Snack Code/List Recursion

Sum list of integers

Haskell:

sum []     = 0
sum (x:xs) = x + sum xs

Scheme:

(define (sum lst)
  (cond (( null? lst) 0)
        (else (let ((x (car lst)) (xs (cdr lst)))
                (+ x (sum xs))))))

Erlang:

sum([])    -> 0;
sum([H|T]) -> H + sum(T).

Smalltalk ?

--Dokondr 13:44, 28 February 2006 (UTC)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.