Skip to content

Instantly share code, notes, and snippets.

@zakki
Created July 16, 2015 03:03
Show Gist options
  • Save zakki/85593f1cbf1fddb0c2a5 to your computer and use it in GitHub Desktop.
Save zakki/85593f1cbf1fddb0c2a5 to your computer and use it in GitHub Desktop.
let f a b _ =
a + b
let f2 a =
f a 1
let () =
print_int (f 1 2 3);
print_newline ();
let f3 = f2 100 in
print_int (f3 2);
for i = 0 to 2 do
let f3 = f2 i in
print_int (f3 2);
print_newline ()
done
(*
$ ocamlc foo.ml -o a.byte
$ js_of_ocaml --disable=opt --pretty a.byte
$ java -jar ~/js/compiler-latest/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js a.js > a.min.js
a.js:91: WARNING - If this if/for/while really shouldn't have a body, use {}
;
^
0 error(s), 1 warning(s)
$ node a.js
3
1011
2
3
$ node a.min.js
function (c){for(var d=b.length,e=Array(d+1),f=0;f<d;f++)e[f]=b[f];e[f]=c;return n(a,e)}
function (c){for(var d=b.length,e=Array(d+1),f=0;f<d;f++)e[f]=b[f];e[f]=c;return n(a,e)}function (c){for(var d=b.length,e=Array(d+1),f=0;f<d;f++)e[f]=b[f];e[f]=c;return n(a,e)}
function (c){for(var d=b.length,e=Array(d+1),f=0;f<d;f++)e[f]=b[f];e[f]=c;return n(a,e)}
function (c){for(var d=b.length,e=Array(d+1),f=0;f<d;f++)e[f]=b[f];e[f]=c;return n(a,e)}
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment