Commit 95127c31 authored by Michael Hanus 's avatar Michael Hanus
Browse files

concatMap added in prelude

parent ca1e0a84
% $Id: report.tex,v 1.6 2000/02/01 21:40:14 mh Exp mh $
% $Id: report.tex,v 1.7 2000/02/02 15:08:05 mh Exp mh $
% $Log: report.tex,v $
% Revision 1.7 2000/02/02 15:08:05 mh
% This is the official version 0.7 of the Curry report.
%
% Revision 1.6 2000/02/01 21:40:14 mh
% Pragma optmatch omitted, Constraint replace by Success,
% literate programming added and some more minor changes
......@@ -2890,7 +2893,7 @@ zip [] [] = []
zip (x:xs) (y:ys) = (x,y) : zip xs ys
~
-- Join three list to one list of triples
zip3 :: [a] -> [b] -> [c] -> [(a,b,c)]
zip3 :: [a] -> [b] -> [c] -> [(a,b,c)] \pindex{zip3}
zip3 [] [] [] = []
zip3 (x:xs) (y:ys) (z:zs) = (x,y,z) : zip3 xs ys zs
~
......@@ -2898,6 +2901,10 @@ zip3 (x:xs) (y:ys) (z:zs) = (x,y,z) : zip3 xs ys zs
concat :: [[a]] -> [a] \pindex{concat}
concat l = foldr (++) [] l
~
-- Map a function from elements to lists and merge the result into one list
concatMap :: (a -> [b]) -> [a] -> [b] \pindex{concatMap}
concatMap f = concat . map f
~
-- Infinite list of repeated applications of a function f to an element x:
-- iterate f x = [x, f x, f (f x),...]
iterate :: (a -> a) -> a -> [a] \pindex{iterate}
......@@ -2962,8 +2969,8 @@ lines (c:cs) = let (l,restcs) = splitline (c:cs) in l : lines restcs
else let (ds,es) = splitline cs in (c:ds,es)
~
-- concatenate a list of strings with terminating newlines
unlines :: [String] -> String \pindex{unlines}
unlines ls = concat (map (++"\ttbs{}n") ls)
unlines :: [String] -> String \pindex{unlines}
unlines ls = concatMap (++"\ttbs{}n") ls
~
~
-- Conversion functions between characters and their ASCII values
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment