Demonstrate how to pick a random element from a list.




random_element = proc [T: type] (a: array[T]) returns (T)
    return(a[array[T]$low(a) + random$next(array[T]$size(a))])
end random_element
 
start_up = proc ()
    po: stream := stream$primary_output()
    d: date := now()
    random$seed(d.second + 60*(d.minute + 60*d.hour))
 
    arr: array[string] := array[string]$["foo", "bar", "baz", "qux"]
 
    for i: int in int$from_to(1,5) do   
        stream$putl(po, random_element[string](arr))
    end
end start_up