how to write a function like (set! x y) ?
- From: abraham <abraham.w@xxxxxxx>
- Date: Mon, 12 Dec 2005 14:51:44 GMT
Hi!
I'm sorry if this has been asked before, but I'm new to scheme, and a search on google didn't yield any results, nor in this newsgroup (although I'm not too good at searching newsgroups) ...
I want to program a function (test x y) that acts like (set! x), so that if I enter
(test a 7)
It sets a to the value of 7.
At first I tried to write the following:
(define (test x y)
(set! x y))
which obviously did not work, because it sets _x_ to y and not the symbol-name contained in x...
Then I had the idea that I could write a function (return a) that returns the value of x, in this case a symbol, and subsitute x in the function with (return x):
(define (test x y) (define (return a) a) (set! (return x) y))
This didn't work either, it says: "set!: not an identifier in: (return x)"
Does anyone have any suggestions on how I can write the function? Thanks for any help. /Abraha .
- Follow-Ups:
- Re: how to write a function like (set! x y) ?
- From: drcode
- Re: how to write a function like (set! x y) ?
- From: Eric Hanchrow
- Re: how to write a function like (set! x y) ?
- Prev by Date: Re: Defining a random range
- Next by Date: Re: Beyond ascii
- Previous by thread: Defining a random range
- Next by thread: Re: how to write a function like (set! x y) ?
- Index(es):
Relevant Pages
|