Last active
December 16, 2015 13:49
-
-
Save rintaun/5444247 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
| let empty selector = selector True True True | |
| let prepend el list = \selector -> selector el list False | |
| let head list = list (\h t e -> h) | |
| let tail list = list (\h t e -> t) | |
| let is_empty list = list (\h t e -> e) |
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
| empty = ->(selector) { selector[_, _, true] } | |
| prepend = ->(el, list) { ->(selector) { selector[el, list, false] } } | |
| head = ->(list) { list[->(h, _, _) { h }] } | |
| tail = ->(list) { list[->(_, t, _) { t }] } | |
| is_empty = ->(list) { list[->(_, _, e) { e }] } | |
| list = prepend["asdf", empty] | |
| head[list] # => "asdf" |
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
| empty = lambda do |selector| | |
| selector.call _, _, true | |
| end | |
| prepend = lambda do |el, list| | |
| lambda do |selector| | |
| selector.call el, list, false | |
| end | |
| end | |
| head = lambda do |list| | |
| list.call(lambda do |h, _, _| | |
| h | |
| end) | |
| end | |
| tail = lambda do |list| | |
| list.call(lambda do |_, t, _| | |
| t | |
| end) | |
| end | |
| is_empty = lambda do |list| | |
| list.call(lambda do |_, _, e| | |
| e | |
| end) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment