[Haskell-cafe] Span function
R J
rj248842 at hotmail.com
Mon Jun 7 08:46:07 EDT 2010
Can someone provide a hand calculation of:
span (< 0) [-1, -2, -3, 0, 1, 2, -3, -4, -5]?
I know the result is ([-1, -2, -3], [0, 1, 2, -3, -4, -5]), but the recursion flummoxes me.
Here's the Prelude definition:
mySpan :: (a -> Bool) -> [a] -> ([a], [a]) mySpan _ [] = ([], []) mySpan p xs@(x:xs') | p x = (x:ys, zs) | otherwise = ([], xs) where (ys, zs) = mySpan p xs'
Thanks.
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100607/ea7268e2/attachment.html
More information about the Haskell-Cafe
mailing list