AW: net.sf.saxon.exslt.Random

"Martin Szugat" <[email protected]>
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <000001c45edd$dad14e30$037ba8c0@JOSHUA>
> What does the signature random:random-sequence(number?, 
> number?) mean? Does it mean that the function can have 0, 1, 
> or 2 arguments, or does it mean that the arguments can be ()? 
> I guess the former, since () wasn't invented in 1.0.

The EXSLT spec says that both parameters are optional, so the function
can have 0, 1 or 2 arguments. The default values should be 1 for
numberOfItems and seed should be equal to current-time (I think it means
fn:current-time()).
 
> So if it has one argument, is this the number of items to be 
> returned, or the seed? The spec doesn't seem to say. Your 
> implementation makes it the seed.

For me it makes more sense that it should be the numberOfItems, but how
can I achieve this with Saxon? Do I have to remove randomSequence(long
seed) from the Random class?

> Your implementation accepts a seed that's a long. This means 
> that supplying 0.1 and 0.2 will give you the same sequence. 
> This doesn't feel right; I think it should be a double.

Ok, what do you suggest to use: Double.doubleToLongBits or
.doubleToRawLongBits? You'll code that?

> I've done some internal changes to make it return values in 
> Saxon's internal data formats to avoid the need for 
> subsequent conversion. Ideally I would make it return an 
> iterator, in which case the sequence could be infinite, but 
> then I'd need somewhere to keep the current state, which is tricky.

Ok, that's why random:random-sequence(1,1) doesn't work well with the
current implementation.

Martin

> 
> Michael Kay
> 
> > -----Original Message-----
> > From: Martin Szugat [mailto:[email protected]]
> > Sent: 30 June 2004 19:28
> > To: [email protected]
> > Subject: net.sf.saxon.exslt.Random
> > 
> > Attached you'll find a ZIP archive with an Eclipse 3.0
> > project including
> > the source code for the net.sf.saxon.exslt.Random class and a
> > corresponding test case called RandomTest. The test is repeated 400
> > times and ensure that
> > 
> > - the random number lies between 0 (inclusive) and 1 (exclusive)
> > - for the same seed the same random numbers are generated
> > - for different seeds, different random numbers are generated
> > 
> > I'll hope you'll find it useful! If so, please notify me when you 
> > integrated it, so I can mention it in my article.
> > 
> > Greetings,
> > 
> > Martin
> > 
> > PS: If you have some suggestions how to improve the code or 
> something 
> > isn't good enough, feel free to contact me! I'll fix it :)
> > 
> > > -----Ursprüngliche Nachricht-----
> > > Von: SourceForge.net [mailto:[email protected]]
> > > Gesendet: Mittwoch, 30. Juni 2004 19:37
> > > An: [email protected]
> > > Betreff: [saxon - Help] RE: random in loop returns same 
> > number each t
> > > 
> > > 
> > > 
> > > Read and respond to this message at:
> > > https://sourceforge.net/forum/message.php?msg_id=2643233
> > > By: mhkay
> > > 
> > > Just send it in when it's tested and I'll integrate it.
> > > Remember to send the test cases too. If you can devise a way 
> > > of making the test repeatable (so it gives the same results 
> > > each time) that will help the regression testing no end.
> > > 
> > > Michael Kay
> > > 
> > > 
> > 
> ______________________________________________________________________
> > > You are receiving this email because you elected to monitor
> > > this forum. To stop monitoring this forum, login to 
> > > SourceForge.net and visit: 
> > > https://sourceforge.net/forum/unmonitor.php?forum_id=94027
> > > 
> > 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.