View stackoverflow.ml
permutation [1;2;3;4;5;6;7;8;9];;
Stack overflow during evaluation (looping recursion?).
View recursive_permutation.ml
let insert_all_positions x l =
let rec aux prev acc l =
match l with
| [] -> (prev @ [x]) :: acc |> List.rev
| hd::tl as l -> aux (prev @ [hd]) ((prev @ [x] @ l) :: acc) tl
in aux [] [] l;;
let rec permutation l =
match l with
View dutch_partition.ml
let swap i j a =
try
let tmp = a.(j) in
a.(j) <- a.(i);
a.(i) <- tmp; a
with
_ -> raise (Invalid_argument "out-of-range")
(* auxiliary function *)
(* a[0 .. smaller - 1] : smaller region
View dutch_partition
let swap i j a =
try
let tmp = a.(j) in
a.(j) <- a.(i);
a.(i) <- tmp; a
with
_ -> raise (Invalid_argument "out-of-range")
(* auxiliary function *)
(* a[0 .. smaller - 1] : smaller region
View reactiveschemes.cpp
InitializeMemory();
foreach input_event do
ComputeOutput();
UpdateMemory();
end
InitializeMemory();
foreach period do
View introrx.md
View listplus.ml
let rec last l =
match l with
| [] -> None
| [x] -> Some x
| _::t -> last t
let biggest_prefix l =
let rec bpre_aux xs ys = match xs with
| [] -> ys
| [x] -> ys
View listplus.mli
(**************************************************************************)
(*
* Listplus
*
*
* Copyright 2016 Van-Chan Ngo.
*
* All rights reserved. This file is distributed under the terms of
* the GNU Lesser General Public License version 2.1, with the
* special exception on linking described in the file LICENSE.
View prob1.ml
(*
* find the shortest substring of str containing the strings str1 str2,...,strm in a list
*)
(* use core for more efficient with long strings *)
open Core.Std
open Printf
(*
* find substring sub in string str forward from pos