Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

how do I average in scheme?

Name: Anonymous 2010-12-26 21:31

im learning scheme and im not very good its my first languages what am i doing wrong

(define (average nums)
   (/ (+ (car nums) (average (cdr nums))) 2))

then i do (average (list 2 3 4 5 6)) but it doesnt work
also how can i do that (average 2 3 4 5 6) gives me the average without doing a list?

please help

Name: Anonymous 2010-12-27 15:14

(/ (foldr + 0 nums) (length nums))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List