Joy

Command

Enter/Return Submit code
Ctrl + Enter Newline
Up / Down Browse history
Ctrl + l Clear display
Ctrl + k Reset toplevel
Tab Indent code

Joy Reference

Circle (with radius 50)
let c = circle 50
Rectangle (with length 100, width 50)
let r = rectangle 100 50
Show shapes c and r on canvas
show [ c; r ]
Clear canvas
clear ()
Transformations
Move c to the right by 50, and up by 100
let c2 = c |> translate 50 100
Move c to the right by 50, and down by 100
note that we put -100 in its own parentheses. we need to do this for negative numbers
let c2 = c |> translate 50 (-100)
Make c 2 times bigger
note the decimal 2.0, it's a float!
let c2 = c |> scale 2.0
Make c half as small
let c2 = c |> scale 0.5
Rotate a rectangle r by 18 degrees
let r2 = r |> rotate 18
Rotate a rectangle r by 18 degrees, 10 times
let rot18 = rotate 18;;
let pattern = r |> repeat 10 rot18;;
show [ pattern ];;
Rotate a rectangle r by 18 degrees and scale it by 0.8 in one transformation
let tr = compose (rotate 18) (scale 0.8)
Rotate a rectangle r by 18 degrees and scale it by 0.8, 10 times
let tr = compose (rotate 18) (scale 0.8);;
let pattern = r |> repeat 10 tr;;
show [ pattern ];;
More shapes!
Ellipse (with x-radius 100, y-radius 50)
let e = ellipse 100 50
Line (from origin to (-50, 50))
let l = line (point (-50) 50)

A compiler from OCaml bytecode to Javascript.

It makes OCaml programs that run on Web browsers. It is easy to install as it works with an existing installation of OCaml, with no need to recompile any library. It comes with bindings for a large part of the browser APIs.

This web-based OCaml toplevel is compiled using Js_of_ocaml.

Command

Enter/Return Submit code
Ctrl + Enter Newline
Up / Down Browse history
Ctrl + k Reset toplevel
Tab Indent code

Try to execute samples

See the generated javascript code