Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@creatrice
Created September 19, 2012 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creatrice/3752385 to your computer and use it in GitHub Desktop.
Save creatrice/3752385 to your computer and use it in GitHub Desktop.
get = Dom.get_text
function apply(f) { function(_) { #counter = Int.to_string(f(String.to_int(get(#counter)))); } }
function incr(x) { x + 1 }
function decr(x) { x - 1 }
function page(){
<h1 id="counter">0</h1>
<h1><span onclick={apply(incr)}>+</span> <span onclick={apply(decr)}>-</span></h1>
}
Server.start(Server.http, { title: "counter", ~page })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment