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 BirdForm = React.createClass( | |
{ | |
getInitialState: function(){ | |
return {birdName:'', wingspan:''}; | |
}, | |
handleBirdNameChange: function(e){ | |
console.log(e.target.value); | |
this.setState({birdName: e.target.value}); | |
}, | |
handleBirdWingspanChange: function(e){ |
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 ParagraphPile = React.createClass( | |
{getInitialState: function(){ | |
return({tog: false}); | |
}, | |
handleClick: function(e){ | |
labeledLog('state', this.state); | |
e.preventDefault(); | |
var tog2 = !(this.state.tog); | |
this.setState({tog: tog2}); | |
}, |
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 birdData = [ | |
{birdName: 'seagull', | |
wingspan: 'eighteen feet'}, | |
{birdName: 'chickadee', | |
wingspan: 'three nanometers'} | |
]; | |
var BirdDisplay = React.createClass( | |
{getInitialState: function(){ |
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
(defn template-match? [template-node data-node] | |
(cond | |
(atomic-node? template-node) | |
(= template-node data-node) | |
(predicate-node? template-node) | |
(predicate-match? template-node data-node) | |
:else | |
(and |
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
function isSortedObject(obj){ | |
//var props = Object.getOwnPropertyNames(obj); | |
var i = 0; | |
for(var k in obj){ | |
if(k != i){ | |
return false; | |
} | |
i++; | |
} | |
return true; |
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
function first(linkedList){ | |
return (linkedList === null) ? null : linkedList[0]; | |
} | |
function rest(linkedList){ | |
return (linkedList === null) ? null : linkedList[1]; | |
} | |
function prepend(x, linkedList){ | |
return [x, linkedList]; |
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
;; sort of like reset | |
(defn thing-1 [game-object-with-state, kw, val] | |
(let [a (get-state-atom game-object-with-state)] | |
(swap! a assoc kw val) | |
game-object-with-state)) | |
;; sort of like swap | |
(defn thing-2 [game-object-with-state, kw, f] | |
(let [a (get-state-atom game-object-with-state)] | |
(swap! a update kw f val) |
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
// makes an infinite sequence (memoized generator) of all integers from supplied n up | |
var intsFrom = function(n){ | |
return { | |
thunk: {realized: false, | |
state: null, | |
deref: function(){ | |
if(this.realized){ | |
return this.state; | |
}else{ | |
console.log("running a computation!!"); |
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
function isFunction(x){ | |
return typeof(x) === 'function'; | |
} | |
function jsBool(x){ | |
return !( x === null || x === undefined || x === false); | |
} | |
function isSeq(x){ | |
return jsBool(x.myType === "seq"); |
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
// ============================================================ | |
// UIDs | |
// should hide the idCounter in a closure, just leaving it global for sake of simplicity here: | |
var idCounter = 0; | |
var nextId = function(){ | |
idCounter = idCounter + 1; | |
return "id_" + idCounter; | |
}; |