Error in rand

Q&A's, tips, howto's
Locked
Fanda
Posts: 253
Joined: Tue Aug 02, 2005 6:40 am
Contact:

Error in rand

Post by Fanda »

Hello all!

It seems that there is a small error in 'rand':

Code: Select all

> (set 'N 10)
10
> (rand 3 N)
(2 0 1 1 0 2 2 2 2 0 2)
> (length (rand 3 N))
11
Length of the generated list should be 10 (= N). 'rand' keeps returning one more than is needed.

This way:

Code: Select all

> (rand 5 0)
(4)
Also:

Code: Select all

> (rand 5 -1)
never returns result (infinite loop).

- Fanda

PS: I am using newLISP v.8.9.0 on Win32 MinGW

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks Fanda, this will work again in 8.9.1

Lutz

Locked