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

Scheme/DrRacket

Name: Anonymous 2012-12-02 12:58

How do you do this shit /prog/?

Write a Scheme function evens-odds (using at least one abstract list function), which consumes a list of numbers lst and produces the difference between the sum of the odd numbers and the sum of the even numbers in the list lst. Some examples follow:


(evens-odds (list 1 2 3 4)) => -2
(evens-odds empty) => 0
(evens-odds (list 2 4 16)) => -22
(evens-odds (list 1 3 7 21 13)) => 45



Note: You should use local function(s) only (in case of need).

Name: Anonymous 2012-12-02 13:41

>>5
Unfortunately we're so restricted to this.

1. We're not allowed to use recursion, we're only allowed to use abstract list methods.
2. We're not allowed to use cdr or car or anything like that. This isn't in the course notes.

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