Search code examples
setschemeracketsetfdr.racket

What's setf and is it a valid function in Dr.Racket?


I have an assignment where I have to define an alias to an expression, in one of the guides we are told to use either setf or lists of lists to define them. To be more specific we need to assign to the alias ADD/SUCC/PRED/etc their lambda calculus value e.g ---> (ADD := (λ m n f x. n f (m f x))) <----.

This, so after replacing them in any given operation with the alias, we can operate them. As i didn't find any clare explanation and i have no idea how to proceed using setf, i would find it really helpful if any of you could give me a tip.

So far to change the values i've used conditionals where if any symbol is equal to the word i need to replace, it does it, but i does not seem efficient.


Solution

  • setf is a Commmon Lisp macro. It does not exist in the default languages available from DrRacket.

    You probably mean set!, set-car!, or set-cdr! if you really mean it is supposed to work with Racket, which is a Scheme decendant.

    Because Racket has many levels of abstraction to the level that you can literally implement any surface syntax in it, it isn't far fetched that one could implement Common Lisp and then you of course should be able to use setf :-)