W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2004

[F&O] LQ-FO-001 - random numbers

From: Liam Quin <liam@w3.org>
Date: Thu, 4 Mar 2004 13:00:33 -0500
To: public-qt-comments@w3.org
Message-ID: <20040304180033.GB16963@w3.org>

Many languages provide a random number generator.  This can
be useful for testing; in my cases I wanted it as part of
generating SVG images.

Although it's possible to write a random number generator in
XQuery, it's hard to do with any efficiency, because a random()
function will always return the same random number (e.g. there's
no assignment to global or hidden variables).

Two obvious workarounds are (1) an external function, which isn't
always possible and isn't likely to be interoperable, and (2)
writing a function random(n) which returns the nth random
number in a series; this can then moderately easily be written
as a recursive function, with some care to avoid overflow.

I'd like to suggest either
(1) adding a random() function, possibly with an integer argument
    as outlined above, or,

(2) defining (in the future) a set of commonly needed external
    functions, and possibly adding a way to indicate that an
    external function may return different values on multiple


Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
Received on Thursday, 4 March 2004 13:39:23 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:18 UTC