on master help sign in
Replace awful scanl version with a saner one
commitd90731e5dbd4bef0cde58971c5a0204aea91b876 authorPaul Koerbitz <paul.koerbitz@theppro.com> dateSat 19 Apr 2014, 19:08 (13 years ago) parent32417da
1 file changed+4−6
benchmarks/fasta/fasta.idr+4−6
benchmarks/fasta/fasta.idr+4−6
@@ -39,12 +39,10 @@ replicate : Int -> Char -> String
3939replicate 0 c = ""
4040replicate n c = singleton c <+> replicate (n-1) c
4141
42−inits : List a -> List a -> List (List a)
43−inits xs [] = [xs]
44−inits xs (h::t) = let xs' = xs ++ [h] in xs :: inits xs' t
45−
46−scanl : (f : acc -> a -> acc) -> acc -> (l : List a) -> List acc
47−scanl f acc l = map (foldl f acc) $ inits [] l
42+scanl : (f : acc -> a -> acc) -> acc -> List a -> List acc
43+scanl f q ls = q :: (case ls of
44+ [] => []
45+ x::xs => scanl f (f q x) xs)
4846
4947accum : (Char,Float) -> (Char,Float) -> (Char,Float)
5048accum (_,p) (c,q) = (c,p+q)