I have to write a Scheme procedure named ‘proc3’ which takes 2 numbers as arguments
(x,y) and returns a procedure which takes a list as an argument and returns a new
list which is the same as the input list but with x added as the first element
and y added as the second element.
I have so far
(define proc3
(lambda ( x y)
(lambda (list a b c)
(list x y c)
)
)
)
The interpreter compiles it fine, but when I give arguments
i.e proc3( 1 2), it says: cannot reference an identifier before definition.
What does that mean?
The code in the question won’t work. Use this as a template for your solution, noticing that a list is just another parameter (I called it
lst) e.g., you don’t have to writelistand enumerate its elements as you did:I’ll let you figure out the details of how to add
xandyat the beginning oflst. For testing it, try something like this: