Created
January 14, 2014 06:45
-
-
Save zealoushacker/8414167 to your computer and use it in GitHub Desktop.
A closure containing a pure function
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
| =begin | |
| Functions containing no free/unbound variables are called pure functions. | |
| Functions containing one or more free variables are called closures. | |
| Adapted from the quick exercise in https://leanpub.com/javascript-allonge/read#closures | |
| In turn, this is adapted from https://gist.github.com/zealoushacker/8091614 | |
| If pure functions can contain closures, can a closure contain a pure function? | |
| Attempt to compose a closure that contains a pure function. | |
| Many thanks to @raganwald! | |
| =end | |
| lambda do |x| | |
| lambda do |y| | |
| lambda { |n| n } | |
| return x | |
| end | |
| end["foo"]["bar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment