Created
August 3, 2011 03:04
-
-
Save heuristicfencepost/1121816 to your computer and use it in GitHub Desktop.
Implementations of "tails" function in Data.List as well as a vaguely related function
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
antitails x = reverse (foldr f1 [] x) ++ [""] | |
where f1 newchar acc = [[newchar]] ++ (map (newchar:) acc) |
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
mytailsl x = (foldl f1 [] x) ++ [""] | |
where f1 acc newchar = (map (f2 newchar) acc) ++ [[newchar]] | |
where f2 currchar currstr = reverse (currchar : (reverse currstr)) |
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
mytailsr x = (foldr f1 [] x) ++ [""] | |
where f1 newchar [] = [[newchar]] | |
f1 newchar acc = [newchar:(head acc)] ++ acc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment