Skip to content

Instantly share code, notes, and snippets.

View marrionluaka's full-sized avatar
🏠
Working from home

marrionluaka

🏠
Working from home
View GitHub Profile
const applyDiscount = (price, discount) =>
moneyToFloat(price) // => Box(3.99)
.fold(cost =>
percentToFloat(discount) // => Box(0.15)
.fold(savings => cost - cost * savings)); // 3.99 - (3.99 * 0.15)
@marrionluaka
marrionluaka / ast.js
Last active May 2, 2017 22:56
Abstract Syntax Tree (JavaScript)
var Node = (function(){
return function _Node(operation, value, leftChild, rightChild){
this.operation = operation;
this.value = value;
this.leftChild = leftChild;
this.rightChild = rightChild;
};
}());
function evaluate(node){