Last active
December 17, 2015 01:19
-
-
Save supki/5527795 to your computer and use it in GitHub Desktop.
WAT
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
#!/usr/bin/env ruby | |
class C | |
def initialize | |
@x = 0 | |
end | |
def f xs | |
if @x < 10 | |
xs << @x | |
@x += 1 | |
f xs | |
else | |
xs | |
end | |
end | |
def g xs | |
if @x < 10 | |
xs << lambda { @x } | |
@x += 1 | |
g xs | |
else | |
xs | |
end | |
end | |
def h xs | |
x = nil | |
10.times do |y| | |
x = y | |
xs << lambda { x + 1 } | |
end | |
xs | |
end | |
end | |
puts C.new.f([]) | |
puts C.new.g([]).map(&:call) | |
puts C.new.h([]).map(&:call) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment