Last active
September 29, 2015 09:46
-
-
Save qwtel/75e6c917c79cb58fe1a3 to your computer and use it in GitHub Desktop.
If JavaScript was written like Clojure...
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 cost(state) { | |
return mul( | |
b, | |
Math.log( | |
reduce( | |
add, | |
map( | |
function(x) {return Math.pow(Math.E, div(x, b))}, | |
vals(x)))))} | |
function price(state, event) { | |
return div( | |
Math.pow(Math.E, div(get(state, event), b)), | |
reduce( | |
add, | |
map( | |
function (x) {return Math.pow(Math.E, div(x, b))}, | |
vals(state))))} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Closing all braces in a single line would be considered really bad style in JavaScript (but also Java, C#, basically anything except Clojure/LISP).
I guess the reason this is accepted in Clojure is that LISPs traditionally had better editor support for editing S-expressions, but it is certainly not making it easier for people coming from Java/JavaScript to adopt Clojure :(