# $Id: random.pliant,v 1.0 2002/02/07 15:19:00 dada Exp $ # http://dada.perl.it/shootout/ module "/pliant/language/context.pli" gvar Int IM := 139968 gvar Int IA := 3877 gvar Int IC := 29573 gvar Int LAST := 42 function gen_random n -> r arg Int n ; arg Float r LAST := (LAST * IA + IC) % IM r := (n * LAST) / IM return r gvar Float result gvar Str s_n := cast ((pliant_script_args translate Address 1) map CStr) Str if (s_n parse (gvar Int n)) while n > 0 result := gen_random(100) n := n - 1 console (string result "fixed 9") eol else console "usage: random.pli <number>" eol