Merge remote-tracking branch 'sergi/master'
Conflicts: index.html
This commit is contained in:
commit
71e669fcb6
4 changed files with 487 additions and 1 deletions
24
index.html
24
index.html
|
|
@ -27,7 +27,8 @@
|
|||
<option value="java">Java Document</option>
|
||||
<option value="csharp">C# Document</option>
|
||||
<option value="c_cpp">C++ Document</option>
|
||||
|
||||
<option value="svg">SVG Document</option>
|
||||
<option value="ocaml">OCaml Document</option>
|
||||
<option value="textile">Textile Document</option>
|
||||
</select>
|
||||
</td>
|
||||
|
|
@ -100,6 +101,7 @@
|
|||
<option value="c_cpp">C/C++</option>
|
||||
<option value="coffee">CoffeeScript</option>
|
||||
<option value="perl">Perl</option>
|
||||
<option value="ocaml">OCaml</option>
|
||||
<option value="csharp">C-Sharp</option>
|
||||
<option value="svg">SVG</option>
|
||||
<option value="textile">Textile</option>
|
||||
|
|
@ -336,6 +338,26 @@ print "\n";
|
|||
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="ocamltext">(*
|
||||
* Example of early return implementation taken from
|
||||
* http://ocaml.janestreet.com/?q=node/91
|
||||
*)
|
||||
|
||||
let with_return (type t) (f : _ -> t) =
|
||||
let module M =
|
||||
struct exception Return of t end
|
||||
in
|
||||
let return = { return = (fun x -> raise (M.Return x)); } in
|
||||
try f return with M.Return x -> x
|
||||
|
||||
|
||||
(* Function that uses the 'early return' functionality provided by `with_return` *)
|
||||
let sum_until_first_negative list =
|
||||
with_return (fun r ->
|
||||
List.fold list ~init:0 ~f:(fun acc x ->
|
||||
if x >= 0 then acc + x else r.return acc))
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="svgtext"><svg
|
||||
width="800" height="600"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue