Skip to content

Instantly share code, notes, and snippets.

@h0lyalg0rithm
Last active August 29, 2015 13:58
Show Gist options
  • Save h0lyalg0rithm/10373924 to your computer and use it in GitHub Desktop.
Save h0lyalg0rithm/10373924 to your computer and use it in GitHub Desktop.
Stacks in CoffeeScript
class Stack
constructor:()->
@dataStore = []
@top = 0
push:(element)->
@dataStore[++@top] = element
pop:()->
@dataStore[--@top]
peek:()->
@dataStore[@top-1]
length:()->
@top
clear:()->
@pop = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment