Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Loops-Do-while/OCaml/loops-do-while-1.ocaml
Normal file
7
Task/Loops-Do-while/OCaml/loops-do-while-1.ocaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let rec loop i =
|
||||
let i = succ i in
|
||||
Printf.printf "%d\n" i;
|
||||
if i mod 6 <> 0 then
|
||||
loop i
|
||||
in
|
||||
loop 0
|
||||
7
Task/Loops-Do-while/OCaml/loops-do-while-2.ocaml
Normal file
7
Task/Loops-Do-while/OCaml/loops-do-while-2.ocaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let do_while f p =
|
||||
let rec loop() =
|
||||
f();
|
||||
if p() then loop()
|
||||
in
|
||||
loop()
|
||||
(** val do_while : (unit -> 'a) -> (unit -> bool) -> unit *)
|
||||
3
Task/Loops-Do-while/OCaml/loops-do-while-3.ocaml
Normal file
3
Task/Loops-Do-while/OCaml/loops-do-while-3.ocaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let v = ref 0 in
|
||||
do_while (fun () -> incr v; Printf.printf "%d\n" !v)
|
||||
(fun () -> !v mod 6 <> 0)
|
||||
13
Task/Loops-Do-while/OCaml/loops-do-while-4.ocaml
Normal file
13
Task/Loops-Do-while/OCaml/loops-do-while-4.ocaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let do_while f p ~init =
|
||||
let rec loop v =
|
||||
let v = f v in
|
||||
if p v then loop v
|
||||
in
|
||||
loop init
|
||||
|
||||
do_while (fun v ->
|
||||
let v = succ v in
|
||||
Printf.printf "%d\n" v;
|
||||
(v))
|
||||
(fun v -> v mod 6 <> 0)
|
||||
~init:0
|
||||
9
Task/Loops-Do-while/OCaml/loops-do-while-5.ocaml
Normal file
9
Task/Loops-Do-while/OCaml/loops-do-while-5.ocaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
let v = ref 0
|
||||
exception Exit_loop
|
||||
try while true do
|
||||
incr v;
|
||||
Printf.printf "%d\n" !v;
|
||||
if not(!v mod 6 <> 0) then
|
||||
raise Exit_loop;
|
||||
done
|
||||
with Exit_loop -> ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue