Re: progv in scheme

2011-09-13 Thread Andrew Gwozdziewycz
On Tue, Sep 13, 2011 at 3:09 PM, Bill Schottstaedt wrote: > if lambda were applicable, this would work in both cases: > > (define-macro (progv vars vals . body) >  `(apply (apply lambda ,vars ',body) ,vals)) > >> (let ((s '(one two)) (v '(1 2))) (progv s v (+ one two))) > 3 >> (progv '(one two) '(

Re: progv in scheme

2011-09-13 Thread Bill Schottstaedt
if lambda were applicable, this would work in both cases: (define-macro (progv vars vals . body) `(apply (apply lambda ,vars ',body) ,vals)) > (let ((s '(one two)) (v '(1 2))) (progv s v (+ one two))) 3 > (progv '(one two) '(1 2) (+ one two)) 3 (running a mystery scheme...)

Re: progv in scheme

2011-09-13 Thread Panicz Maciej Godek
2011/9/13, Ian Price : >> Hello, >> Is there any clever way of binding values to the list of unknown >> symbols in scheme? > I have to admit, I don't understand why you would want to bind values > to a list of _unknown_ symbols; changing random bindings is just asking > for trouble. :-) The existe

Re: progv in scheme

2011-09-13 Thread Ian Price
Panicz Maciej Godek writes: > Hello, > Is there any clever way of binding values to the list of unknown > symbols in scheme? I have to admit, I don't understand why you would want to bind values to a list of _unknown_ symbols; changing random bindings is just asking for trouble. :-) > In common

Re: progv in scheme

2011-09-13 Thread Bill Schottstaedt
> and that I don't know what's in that list. oops, I missed that requirement. hmmm -- there must be a way.

Re: progv in scheme

2011-09-13 Thread Ludovic Courtès
Hi, Panicz Maciej Godek skribis: > for now, the problem is that I want to bind the variables that are > contained within a list, and that I don't know what's in that list. I would recommend using (ice-9 match): (match '(1 2 3) ((a b c) `((a . ,a) (b . ,b) (c . ,c => ((a . 1) (b .

Re: progv in scheme

2011-09-13 Thread Bill Schottstaedt
I think this works in Guile 1.8.7 (I don't have a later version): (define-macro (progv vars vals . body) `(let (,@(map (lambda (var val) (list var val)) (cadr vars) (cadr vals))) ,@body)) (progv '(one two) '(1 2) (+ one two)) 3 Maybe pre

Re: progv in scheme

2011-09-13 Thread Andrew Gwozdziewycz
On Tue, Sep 13, 2011 at 12:04 PM, Panicz Maciej Godek wrote: > 2011/9/13, Andrew Gwozdziewycz : >> >> Seems likely that you could use `syntax-case' to create a `let` out of >> these: >> >> (define-syntax progv >>   (lambda (stx) >>     (define (create-bindings syms vals) >>       (datum->syntax st

Re: progv in scheme

2011-09-13 Thread Panicz Maciej Godek
2011/9/13, Andrew Gwozdziewycz : > > Seems likely that you could use `syntax-case' to create a `let` out of > these: > > (define-syntax progv > (lambda (stx) > (define (create-bindings syms vals) > (datum->syntax stx (zip (syntax->datum syms) (syntax->datum vals > (syntax-case s

Re: progv in scheme

2011-09-13 Thread Andrew Gwozdziewycz
On Tue, Sep 13, 2011 at 9:54 AM, Panicz Maciej Godek wrote: > Hello, > Is there any clever way of binding values to the list of unknown > symbols in scheme? > > In common lisp there is a form "progv" that takes the list of symbols > and their corresponding values and binds them within the body of

Re: progv in scheme

2011-09-13 Thread Andrew Gwozdziewycz
On Tue, Sep 13, 2011 at 10:25 AM, Andrew Gwozdziewycz wrote: > On Tue, Sep 13, 2011 at 9:54 AM, Panicz Maciej Godek > wrote: >> Hello, >> Is there any clever way of binding values to the list of unknown >> symbols in scheme? >> >> In common lisp there is a form "progv" that takes the list of symb

progv in scheme

2011-09-13 Thread Panicz Maciej Godek
Hello, Is there any clever way of binding values to the list of unknown symbols in scheme? In common lisp there is a form "progv" that takes the list of symbols and their corresponding values and binds them within the body of progv. It is possible to do it using eval, like this: (define (bind-and