Skip to content

Instantly share code, notes, and snippets.

@bpot
Created October 20, 2009 04:57
Show Gist options
  • Save bpot/214010 to your computer and use it in GitHub Desktop.
Save bpot/214010 to your computer and use it in GitHub Desktop.
cursor = 0
a = (1..5).to_a
b = []
stack = []
while true
if cursor < a.size
b << a[cursor]
stack << cursor
cursor += 1
p b
else
if stack.empty?
break
end
b.pop
cursor = stack.pop
cursor += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment