Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active July 20, 2017 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/c1197ad34c943fc6f29122d8da58de25 to your computer and use it in GitHub Desktop.
Save deque-blog/c1197ad34c943fc6f29122d8da58de25 to your computer and use it in GitHub Desktop.
||| Given a predicate of type (a -> Bool), it transforms:
||| - a step function taking values of type `a`
||| - into one taking the values of type `a` that fulfills the predicate
filtering : (a -> Bool) -> Transducer acc s s a a
filtering pf = statelessTransducer $
\next, acc, a =>
if pf a
then next acc a
else pure (Continue acc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment