scsh-users
[Top] [All Lists]

Re: Random Numbers

To: scsh-news@zurich.csail.mit.edu
Subject: Re: Random Numbers
From: Michel Schinz <Michel.Schinz@epfl.ch>
Date: Mon, 17 Nov 2003 08:13:03 +0100
Organization: EPFL
Brian King <linux_king@yahoo.com> writes:

> How do I generate random numbers in SCSH 0.6.4? I see that SRFI-27
> is included, but I can't seem to access random-integer.

You have to open the structure srfi-27 to make random-integer
accessible. If you are working interactively, this is done using the
,open command. Here is an example:

----------------------------------------------------------------------
[lamppc3 ~]% scsh
Welcome to scsh 0.6.4 (Olin Shivers)
Type ,? for help.
> ,open srfi-27
Load structure srfi-27 (y/n)? y
[srfi-23]
[srfi-27 /home/linuxsoft/apps/scsh-0.6.4/lib/scsh/srfi/srfi-27.scm]
> (random-integer 14)
12
----------------------------------------------------------------------

If you are writing a script, you need to add a "-o" to scsh's command
line. Here is an example script (which assumes that scsh is installed
in /usr/local):

----------------------------------------------------------------------
#!/usr/local/bin/scsh \
-o srfi-27 -s
!#

(display (random-integer 14))
(newline)
----------------------------------------------------------------------

Michel.

<Prev in Thread] Current Thread [Next in Thread>