[comp.lang.functional] O LANGUAGE DESIGNER, REMEMBER THE POOR USER

news@usc.edu (05/05/90)

In article <3738@castle.ed.ac.uk> aipdc@castle.ed.ac.uk
(Paul D. Crowley) writes: 

   Warning: I don't actually know what I'm talking about.

So maybe I shouldn't respond?

   I tried as hard as I could to think of a way of randomizing an
   array in Prolog.  I can think of several ways of doing it in O(n^2)
   time.  I can think of one very tedious way of doing it in O(n
   log(n)) time.  I don't know how to do it in O(n) time, despite the
   fact that it can be done extremely efficiently in any imperative
   language.

Prolog does not have well structured array primitives.

   Is there no way to handle arrays in an applicative way, similar to
   the way ML has applicative assignments?

There are several ways.  They all boil down to providing primitives
adequate for the job.  For example, I know at least one language
which, given an array of positive integer constants, has a primitive
which will return numbers chosen pseudorandomly from the range 1..n
for each n.

Variations on this theme might involve constructing an array from a
set of precomputed random values.

In any event, don't let the array structure bother you.  Just demand
corresponding structure from your language.  [not to be confused with
imperative structures such as loops.]

Wulkwa