Skip to content

Instantly share code, notes, and snippets.

@tsnow
Created July 21, 2013 13:46
Show Gist options
  • Save tsnow/6048617 to your computer and use it in GitHub Desktop.
Save tsnow/6048617 to your computer and use it in GitHub Desktop.
def f(n)
@q ||= []
[email protected](n)
puts [@q,v,n].inspect
return -n if v
@q.push(n)
n
end
=begin
1.9.3p393 :053 > f(f(-1))
[[], nil, -1]
[[], -1, -1]
=> 1
1.9.3p393 :054 > f(f(2))
[[], nil, 2]
[[], 2, 2]
=> -2
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment