firstHalf :: [a] -> [a]
firstHalf list0 = div list0 list0
where
div (a,b:arg) (r:res) = r:div arg res
div _ _ = []
Thursday, February 25, 2010
Lazy list division (Haskell)
Subscribe to:
Posts (Atom)
List of random ideas in programming/CS.
firstHalf :: [a] -> [a]
firstHalf list0 = div list0 list0
where
div (a,b:arg) (r:res) = r:div arg res
div _ _ = []