Branch: Tag:

2002-04-17

2002-04-17 14:13:17 by Martin Nilsson <mani@lysator.liu.se>

Added random function. Does what random-element does in LISP.

Rev: lib/modules/Array.pmod:1.67

65:    int i = sizeof(arr);       while(i) { -  int j = random(i--); +  int j = predef::random(i--);    if (j != i) {    mixed tmp = arr[i];    arr[i] = arr[j];
666:    [d2, d1] = low_greedy_diff(d2, d1);    return low_greedy_diff(d1, d2);   } +  + //! Returns a random element from the @[in] array. + mixed random(array in) { +  return in[predef::random(sizeof(in))]; + }