[plt-scheme] Conditional bind then do something
y1wm6lg02 at sneakemail.com wrote:
> Just posted to comp.lang.scheme...
Wait at least a day before making a duplicate post.
Why? Well, if person A answers on this list, there
is no reason why person B, should spend his time
answering on c.l.scheme.
> Hi, I'd like a let... binding to extend beyond the let. The idea
> is to bind the variables to one thing or another, then pass them to
> some subsequent procedure, without using set!, etc.
>
> Something like the following python
>
> def some_function(arg):
> if some_test(arg):
> var1=123
> var2=456
> else:
> var1="xyz"
> var2="abc"
> do_blaaa(var1, var2)
How about this:
(define (some-function arg)
(apply do-blaaa
(if (some-test arg)
(list 123 456)
(list "xyz" "abc")))
?
Alternative:
(define (some-function arg)
(define-values (arg1 arg2) (if (some-test arg)
(values 123 456)
(values "xyz" "abc"))
(do-blaaa arg1 arg2))
--
Jens Axel Søgaard