[plt-scheme] How do I convert (values ...) to something I can do something with?

From: Neil Toronto (ntoronto at cs.byu.edu)
Date: Wed Mar 10 13:50:00 EST 2010

Impressive. Most impressive. I especially like this:

     (let-values+ ([xs 10]
                   [(y) 2])
       (list xs y))
     =>
     (list (list 10) 2)

It's a base case for return patterns like (x . xs)! Ha ha!

Genius.

Neil

Jay McCarthy wrote:
> Ask and you receive.
> 
> I also implemented rest-values and optional values because it was easy to do.
> 
> (let-values+ ([x 10]
>                [(y) 2])
>               (list x y))
>  =>
>  (list (list 10) 2)
> 
>  (let-values+ ([(x [z 3]) 11]
>                [(y) 2])
>               (list x y z))
>  =>
>  (list 11 2 3)
> 
>  (let-values+ ([(x #:foo z) (values+ 12 #:foo 3)]
>                [(y) 2])
>               (list x y z))
>  =>
>  (list 12 2 3)
> 
> Jay
> 
> On Wed, Mar 10, 2010 at 8:28 AM,  <hendrik at topoi.pooq.com> wrote:
>> On Tue, Mar 09, 2010 at 10:27:03PM -0700, Jay McCarthy wrote:
>>> I use multiple value returns _a lot_.
>>>
>>> I try to never overload lists or pairs and instead always make
>>> structs. I try to limit myself to structs that "make sense" in the
>>> wild as opposed to ones that will only be produced/consumed by a
>>> single function; I find that in those cases I really want multiple
>>> values.
>>>
>>> However, multiple values have a problem that when you get more than a
>>> few it is complicated to remember which is which because all you have
>>> is positions. At least with function calls you can have keyword args.
>>> In those cases, I let myself use a struct, but I feel bad about it.
>> Arguments and results are category-theoretical duals.  If you have
>> multiple arguments, you should have multiple results.  If you have
>> keyword arguments, you should have keyword results.  Get with it,
>> language designers!
>>
>> -- hendrik  :-)
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.