vary=. (+ ?@:(10"0))

Marshall

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Adrian May
Sent: Wednesday, March 23, 2011 7:44 AM
To: [email protected]
Subject: [Jprogramming] Problem with random numbers

Hi folks,

You probably already guessed what the problem is. I want to write something
like:

n=.100
vary =. +&(?10)
n=.vary n
n
n=.vary n
n
n =. vary^:10 (100)
n

but it only evaluates the ? once and reuses that value. I want a different
number every time. How do I do that?

Adrian.

PS: I was hoping to keep my whole program to one line just to scare people.
It seems to work better in a function but even then I have problems
sometimes. What's the logic behind whether it re-evaluates ? or not?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to