diff --git a/Libraries/Gast/Gen.dcl b/Libraries/Gast/Gen.dcl index 5d4a97ba512999dd7455e1f436e2fb2e25eeda6e..3079bc4c7a20ca3151459cec16f6f2a36cfe8759 100644 --- a/Libraries/Gast/Gen.dcl +++ b/Libraries/Gast/Gen.dcl @@ -54,7 +54,7 @@ genState :: GenState * @param A list of random numbers (e.g. aStream) * @result An inifinite list of strings */ -ggenString :: Int Real Int Int RandomStream -> [String] +ggenString :: !Int !Real !Int !Int !RandomStream -> [String] derive ggen Int, Bool, Real, Char, String derive ggen UNIT, PAIR, EITHER, CONS of gcd, OBJECT of gtd, FIELD of d, RECORD of grd diff --git a/Libraries/Gast/Gen.icl b/Libraries/Gast/Gen.icl index 71b02341ad8c3ccdb6371fff13de5e47cad17fe5..996f058a0ed6a401b4fa25326290164a81be02ce 100644 --- a/Libraries/Gast/Gen.icl +++ b/Libraries/Gast/Gen.icl @@ -194,17 +194,18 @@ where Nothing -> f s Just limit -> take limit $ f s -ggenString :: Int Real Int Int RandomStream -> [String] +ggenString :: !Int !Real !Int !Int !RandomStream -> [String] ggenString maxlen factor minchar maxchar stream = rndStrings stream where rndStrings [len:rnd] # len = toInt ((randIntToReal len) ^ factor * (fromInt maxlen - 0.5)) - # (chars,rnd) = seqList (repeatn len genElem) rnd + # (chars,rnd) = genElems [] len rnd string = {c \\ c<-chars} = [string:rndStrings rnd] where - genElem :: RandomStream -> .(Char, RandomStream) - genElem [r:rnd] = (toChar (minchar+((abs r) rem (maxchar+1-minchar))), rnd) + genElems :: ![Char] !Int !RandomStream -> (![Char], !RandomStream) + genElems cs 0 rnd = (cs,rnd) + genElems cs n [r:rnd] = genElems [toChar (minchar+((abs r) rem (maxchar+1-minchar))):cs] (n-1) rnd randIntToReal :: Int -> Real randIntToReal x = (toReal x + if (x >= 0) 0.0 4294967296.0) / 4294967295.0