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

2010-10-15 Thread Joe Python
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


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?

- Joe
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


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

2010-10-15 Thread Alonso Andres
2010/10/15 Joe Python jopyt...@gmail.com:
 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

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users