University of Alabama
Department of Computer Science
)given a non-empty list , return the last element of the list.
)that is similar to the function composition function,
o. The function
fshould take two arguments, and the function
gshould take one argument. The definition mathematically is . For example, the code
(val oddSum? (o2 (o not even?) +))followed by
(oddSum? 1 2)will return
(oddSum? 3 5)will return
)or the identity function, which simple returns its argument .
), which is like the function
curry, except that it creates a function that takes one argument, ignores it, and always returns the value . For example, given the code
(val return0 (curryConst 0)), then
(return0 1)returns 0,
(return0 2)returns 0, etc.
)that returns a one argument function that does the following. The arguments , , and and all one argument functions. Assume that the name of the single argument of the returned function is
x. When the returned function is evaluated, if
(p x)is true, then the value
(t x)is returned. If
(p x)is false, then the value
(f x)is returned. For example, given
(val zeroOrValue (funIf even? id return0), then the following ensues:
-> (zeroOrValue 1) 0 -> (zeroOrValue 2) 2 -> (zeroOrValue 3) 0 -> (zeroOrValue 4) 4
)where is a list of numbers, returns the sum of the elements of which are even. For example
(sumEvens `(1 2 3 4))returns 6. You may use
foldlas defined in the textbook, as well as any of the functions from this MP (hint!). However, the body of
sumEvensmust not contain any conditionals (
MP2.scm. In your email, set the subject line to ``CS603MP2''. The attachment should contain your name, set out as a comment. For example:
; Joel Jones (define add1 (x) (+ x 1))
This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.61)
Copyright © 1993, 1994, 1995, 1996,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 0 -nonav MP2.tex
The translation was initiated by on 2004-03-06