(* ** Course: Concepts of Programming Languages (BU CAS CS 320) ** Semester: Summer I, 2009 ** Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu) *) // // author: Hongwei Xi (hwxi AT cs DOT bu DOT edu) // (* ****** ****** *) staload RAND = "libc/SATS/random.sats" (* ****** ****** *) #define MAX 100000000 // 10^8 (* ****** ****** *) // // generating a list of length [n] in which each element // is randomly chosen to be a natural number less than [MAX] // extern fun list0_randgen (n: int): list0 int implement list0_randgen (n) = loop (n, list0_nil ()) where { fun loop (n: int, res: list0 int): list0 int = if n > 0 then loop (n, list0_cons ($RAND.randint MAX, res)) else res // end of [loop] } // end of [list0_randgen] (* ****** ****** *) (* end of [list0_randgen.dats] *)