Created
May 23, 2011 13:10
-
-
Save msgodf/986659 to your computer and use it in GitHub Desktop.
Attempt to add list comprehension sugar to lazy lists
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
range = (function(s,e){var i=s,r={};f=fuction(){r[i+1]=f;i++;return i;};r[i]=f;r.length=e-s;return r;}; | |
some_range = range( 0 , 10 ); | |
for ( i = 0 ; i <= some_range.length ; ++i ) { | |
console.log( some_range[ i ]() ); | |
} |
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
range = (s,e) -> | |
i = s | |
r = | |
length: e - s | |
f = -> | |
i = i + 1 | |
r[ i ] = f | |
i | |
r[ i ] = f | |
r | |
console.log value() for value in range( 0 , 10 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment