Last active
March 4, 2016 23:59
-
-
Save ardcore/a787c036c3ac39e64d5e to your computer and use it in GitHub Desktop.
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
'use strict'; | |
let assert = (condition) => { | |
if (!condition) throw new Error('assertion error') | |
} | |
let sum = (_,a,b) => a+b | |
let mul = (_,a,b) => a*b | |
let sub = (_,a,b) => a-b | |
let div = (_,a,b) => a/b | |
let rem = (_,a,b) => a%b | |
assert( sum`${1} ${2}` == 3 ) | |
assert( mul`${3} ${4}` == 12 ) | |
assert( sub`${6.5} ${3}` == 3.5 ) | |
assert( div`${15} ${3}` == 5 ) | |
assert( rem`${12} ${5}` == 2 ) | |
let result = div`${ | |
sub`${ | |
mul`${ | |
sum`${1} ${2} | |
`} ${2} | |
`} ${1}` | |
} ${2}` | |
assert( result == (((1+2)*2)-1)/2 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment