chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] newbie question - nth-value ?


From: Alonso Andres
Subject: Re: [Chicken-users] newbie question - nth-value ?
Date: Fri, 15 Oct 2010 23:16:49 -0300

2010/10/15 Joe Python <address@hidden>:
> When I try to call the builtin 'nth-value' , I was expecting a number,
> instead I am getting a error.
>
> <snip>
> #;1> (nth-value 2 '(2 3 4 5))
> Error: (list-tail) out of range
> ((2 3 4 5))
> </snip>

You are expecting NTH-VALUE to do what LIST-REF actually does:

#;1> (list-ref '(2 3 4 5) 2)
4

> The documentation says ;
> [syntax] (nth-value N EXP)
>
> Returns the Nth value (counting from zero) of the values returned by
> expression EXP.
>
> Did I interpret it wrong?

Yes. NTH-VALUE is intended to be used with expressions that return
multiple values, using VALUES:

#;2>  (nth-value 2 (values 2 3 4 5))
4

---
                                     Alonso



reply via email to

[Prev in Thread] Current Thread [Next in Thread]