File: ZipTT.lhs

package info (click to toggle)
lhs2tex 1.9-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,544 kB
  • ctags: 28
  • sloc: haskell: 3,364; sh: 2,773; makefile: 349
file content (20 lines) | stat: -rw-r--r-- 664 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
%include typewriter.fmt
%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" 

\begingroup
\let\origtt=\texfamily
\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}
\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}
\endgroup