[Prev][Next][Index][Thread]

Re: How do I turn values() into a list?



In article <slrn84bbs3.7hq.neelk@brick.cswv.com>, neelk@alum.mit.edu wrote:

> Hi,
> 
> One of my little projects is to write a little package implementing a
> lazy evaluation package for Dylan (akin to delay/force in SICP). It's
> been easy and fun, except for one niggle: how do I capture an unknown
> number of multiple return values into a sequence?
> 
> Ideally, I'd like something like this:
> 
>   listify(values(5,9)) => (5, 9) // a list with two elements
>   
>   listify(values(1,2,3)) => (1, 2, 3) // a list with 3 elements
>   
>   listify(values()) => #() // a list with no elements
> 
> but I can't figure out how. Any ideas? 

OK, I think I'm confused about what you want.

listify is trivial to write:

   define method listify(#rest args)
      args;
   end method;

You can't pass the result of values() to it -- it wants actual arguments.

You can capture the results of values() into a list with:

   let (#rest x) = values(1,2,3,4);

If you do this then you don't need listify().


-- Bruce



Follow-Ups: References: