This file contains hidden or 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
| _ = require "lodash" | |
| {Model, Collection} = require "backbone" | |
| #Creating a simple todo collection | |
| class Todo extends Model | |
| defaults: | |
| title: "", | |
| completed: false |
This file contains hidden or 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
| # Setup Backbone.Model, Backbone.Collection, Backbone.View | |
| {Model, Collection, View} = Backbone | |
| #BASIC APP | |
| ### | |
| recall that coffeescript will wrap our app | |
| in a function that prevents us from polluting | |
| the global scope. | |
| We define App as a globally so we can play with it |
This file contains hidden or 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
| var Node = function(data, parent){ | |
| this.children = null; | |
| if(data === undefined){ | |
| data = null; | |
| } | |
| parent !== undefined?parent.addChild(data):this.data = data; | |
| }; | |
| Node.prototype.addChild = function(child){ | |
| var newNode; |
This file contains hidden or 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
| var DigitalNode = function(data){ | |
| this.ref = null; | |
| data === undefined? this.data = null: this.data = data; | |
| }; | |
| var Trie = function(){ | |
| this.primes = [2]; |
This file contains hidden or 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
| class List | |
| attr_accessor :items | |
| def initialize(*args) | |
| @items = digest(args) | |
| end | |
| def insertAfter(item, newItem, items=@items) | |
| if(items.car == item) | |
| items.cdr = Cons.new(newItem, items.cdr) |
This file contains hidden or 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
| #### | |
| # first->next list | |
| #### | |
| class HashyList | |
| def initialize(*args) | |
| @first=nil | |
| @next=nil | |
| @items = {} | |
| args != [] ? digest(args) : @items[@first] = @next | |
| end |
This file contains hidden or 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
| class Node | |
| attr_accessor :data, :next | |
| def initialize(data=nil) | |
| @data = data | |
| end | |
| end |
This file contains hidden or 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
| ### | |
| # Node List | |
| ### | |
| class Node | |
| attr_accessor :val, :next | |
| def initialize(val,next=nil) | |
| @val=val | |
| @next=next | |
| end |