Created
January 11, 2019 08:28
-
-
Save lucamolteni/913645b1e07d1764800964a173f7227b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module Main where | |
| import Data.List.Zipper | |
| import Prelude(IO, (==), mod, print) | |
| main :: IO () | |
| main = print (filter' (\x -> x `mod` 2 == 0) zipper) | |
| myList = [1..100] | |
| zipper = fromList myList | |
| filter' p = foldrz (\z xs -> if (p (cursor z)) | |
| then ((cursor (left z)), (cursor z)) : xs | |
| else xs) [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment