Created
July 4, 2011 15:19
-
-
Save 23Skidoo/1063476 to your computer and use it in GitHub Desktop.
Sharing map (cleaned-up Core listing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sharingMap1 :: [([a], a, Maybe a)] -> (# Bool, [a] #) | |
sharingMap1 [] = (# False, [] #); | |
sharingMap1 ((ds_diz, y1_adI, Nothing):ys) = | |
let (# ww1_skq, ww2_skr #) = sharingMap1 ys | |
in case ww1_skq of { | |
False -> (# False, ds_diz #); | |
True -> (# True, (y1_adI:ww2_skr) #) | |
} | |
sharingMap1 ((ds_diz, y1_adI, Just y2):ys) = | |
let (# ww1_skq, ww2_skr #) = sharingMap1 ys | |
in (# True, (y2:ww2_skr) #) | |
sharingMap :: (a -> Maybe a) -> [a] -> Maybe [a] | |
sharingMap f xs = | |
case sharingMap1 (zip3 (tails xs) xs (map f xs)) | |
of _ { (# m, ww2_skr #) -> | |
case m of _ { | |
False -> Nothing | |
True -> Just ww2_skr | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment