Skip to content

Instantly share code, notes, and snippets.

@supki
Last active December 17, 2015 01:19
Show Gist options
  • Save supki/5527795 to your computer and use it in GitHub Desktop.
Save supki/5527795 to your computer and use it in GitHub Desktop.
WAT
#!/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