include "primitives.alh" Integer seed = 1 Float function random(): // Linear Congruential Generator Integer a Integer c Integer m // Parameters from Numerical Recipes a = 1664525 c = 1013904223 m = 4294967296 // Do the generation and update the seed seed = integer_modulo(a * seed + c, m) // The seed is the new value return seed / m Integer function random_interval(a : Integer, b : Integer): return cast_f2i(random() * (b - a) + a) Element function random_choice(list : Element): return read_edge_dst(read_out(list, random_interval(0, read_nr_out(list) - 1)))