Page 1 of 1

setf and cons

Posted: Sat Feb 20, 2010 2:23 pm
by tomtoo
Hey guys,

given this:

Code: Select all

(define (c cc)(setf (eval (cc 0)) (cons (cc 1) '())))
I get this:

Code: Select all

ERR: no symbol reference found
I see in the manual that this is normal, but I'd like to find an alternative way of making

Code: Select all

("this" "that")
into something that results from something like

Code: Select all

(set 'this "that")
let me know if I haven't provided enough info. it's a bad habit...:-)

Re: setf and cons

Posted: Sat Feb 20, 2010 4:35 pm
by Lutz
Do you mean this?

Code: Select all

(define (c cc)
	(set (sym (cc 0)) (cons (cc 1) '())))

(c '("this" "that")) => ("that")

; the symbol 'this' is now set to ("that")

this => ("that")

Re: setf and cons

Posted: Sat Feb 20, 2010 7:52 pm
by tomtoo
Yep, I think so, thanks. I think it was "sym" that I was missing.

I need to memorize all the functions, I guess, because when I need them I either can't remember them or can't find them.