Supplement to Deren's excellent response:

On 8/6/2017 12:12 AM, wrote:
new to racket‎.

> (foldr + 0 '(1 2 3)) 6


> (foldr and #t '(#t #f)) and: bad syntax and

The list iteration functions such as */foldr /*require a mapping/combining function. /*and*/ is not a function, but rather a special form known as a macro.

In this case you can make it work by wrapping the /*and */in a function of 2 arguments: e.g., (lambda (a b) (and a b)). More generally, because a fold can be passed any number of lists as arguments, the fold combining function requires N+1 arguments where N is the number of lists.

/*or*/ also is a macro, and must be treated the same way. Both /*and */and /*or */can take any number of arguments.

As Deren mentioned, there are /*andmap */and /*ormap */functions which you can use instead of a fold.

Hope this helps,

You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to