
October 30th, 2012, 03:12 AM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: San Francisco Bay
|
|
You basically have it, but as you foreshadowed, your syntax is completely wrong. First thing: as an expression, an unquoted list is a function call. Thus, (#f) is not the literal #f, but the function #f (which doesn't exist) evaluated with no arguments. This is an error. Similarly, (L) is not the list L, but the value of L considered as a function and evaluated with no arguments. Next: the empty list is (), not (" ") (which is a singleton list with its one element being a string with one character). Next:
Code:
(else removefirst(- n 1)(cdr L))
does not do what you think it does: when the 'else' clause is reached, the three expressions 'removefirst', '(- n 1)', and '(cdr L)' are evaluated in turn, and the value of (cdr L) is returned as the value of the cond expression. This is not what you want. As I stated earlier (and as you should know, since you used the syntax in your first post), to evaluate removefirst with the two arguments, you use the expression (removefirst (- n 1) (cdr L)). Finally, 'removefirst' and 'RemoveFirst' are not equivalent, since Scheme is case-sensitive.
|