
Newbie: using map, apply, for-each
Howdy,
I'm sorry if this is a frequently asked question, but I've been
searching the web and have not been able to find an answer so far. I
have been trying to learn some Scheme on my own and I was doing okay
until I came across map, apply and for-each.
Here is some code that might summarize my question:
(define first -5)
(define second 8)
(abs first)
(abs second)
(map abs '(-5 8))
(map abs '(first second))
The responses that I get from DrScheme are:
(abs first) returns 5 -- which I expected
(abs second) returns 8
(map abs '(-5 8)) -- returns (5 8)
However, (map abs '(first second)) returns:
abs: expects argument of type <real number>; given first
So, it looks like the variables that I'm passing to map are not being
resolved. I have experimented with the 'values' function -- but
without much luck.
Can anyone point me in the right direction? I'm sure that I'm missing
something obvious about how to get this to work correctly.
Thank you very much!
Sent via Deja.com http://www.*-*-*.com/
Before you buy.