File: ZipMath.lhs

package info (click to toggle)
lhs2tex 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,976 kB
  • sloc: haskell: 4,408; makefile: 314; sh: 221
file content (20 lines) | stat: -rwxr-xr-x 616 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
%let array=True
%include stupid.fmt
%subst code a = "\begin{colorarray}{@{}lcl@{}}'n" a "\end{colorarray}'n" 

%align 28
\begin{code}
zip                        :: [a] -> [b] -> [(a,b)]
zip                        =  zipWith  (\a b -> (a,b))

zipWith                    :: (a->b->c) -> [a]->[b]->[c]
zipWith z (a:as) (b:bs)    =  z a b : zipWith z as bs
zipWith _ _      _         =  []

partition                  :: (a -> Bool) -> [a] -> ([a],[a])
partition p xs             =  foldr select ([],[]) xs
   where select x (ts,fs) | p x       = (x:ts,fs)
                          | otherwise = (ts,x:fs)
\end{code}