Skip to content

Instantly share code, notes, and snippets.

@qwtel
Last active September 29, 2015 09:46
Show Gist options
  • Save qwtel/75e6c917c79cb58fe1a3 to your computer and use it in GitHub Desktop.
Save qwtel/75e6c917c79cb58fe1a3 to your computer and use it in GitHub Desktop.
If JavaScript was written like Clojure...
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))))}
@qwtel
Copy link
Author

qwtel commented Sep 29, 2015

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 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment