I just can't seem to figure out what is returned from this code and it is
driving me nutz.
(define sentence '(this is a sentence))
sentence ; ==> (this is a sentence) which is a list containing 4 items
(first sentence) ; ==> this
OK ... here is my problem. I know that the contents of the first item in
the constant 'sentence' is the word 'first' (my quotes). But I don't know
how to tell the type of the first item. It isn't a string and it isn't a
This won't work:
(string (first sentence)) ; ==> returns an error that it was expecting an
argument of type <character>, given this.
Also, while playing with strings in Scheme, I came across the
char-alphabetic?, char-numeric?, symbol? procedures.
I believe (wrongly??) that strings can contain any ASCII character. And
more routinely can contain an apostrophe character but could contain other
symbols like +-/\#.* etc. Is there any easy way to test for special
characters in a string that can be used as a procedure like a + or -?
(Other than by having a slew of cond or if statements.)
And to those who recommended I pick up a copy of the Little Schemer - it
arrives in two days ::)))
My objective is to parse a string (containing a given character) to produce
a list of string items. From there I wanted to see
if I could turn that into a procedure.
"(define (cube-number val) (* val val val)))"
I thought I would need to parse the string and create a list of each key
item that might look like this:
(list "(" "define" "(" "cube-number" "val" ")" "(" ... etc)
So far this is an intellectual exercise to (a) play with strings and quoted
lists and (b) see if I can parse it (should be relatively easy but '(a b)
stuff has me stuck - see above), and (c) once parsed, see if I can then
execute what I get.
The (c) part may be well beyond me but (a) and (b) should be within reach, I
The on-line help and DrScheme help aren't especially 'helpful' in these
areas. I was hoping to see some example code.
All suggestions gratefully received.
PS - to all USA students / colleagues, my thoughts are with you, we are
family (I'm an Aussie). Wish to God I could help - just don't know how.