setf and cons

Q&A's, tips, howto's
Locked
tomtoo
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

setf and cons

Post 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...:-)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: setf and cons

Post 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")

tomtoo
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

Re: setf and cons

Post 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.

Locked