(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# based on the following: | |
# http://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/ | |
# http://blog.caplin.com/2013/09/18/merging-two-git-repositories/ | |
git clone repo_main | |
git clone repo_sub | |
cd repo_main | |
git remote add repo_sub ../repo_sub | |
git fetch repo_sub |
permutation [1;2;3;4;5;6;7;8;9];; | |
Stack overflow during evaluation (looping recursion?). |
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 |
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 |
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 |
InitializeMemory(); | |
foreach input_event do | |
ComputeOutput(); | |
UpdateMemory(); | |
end | |
InitializeMemory(); | |
foreach period do |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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 |
(**************************************************************************) | |
(* | |
* 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. |
(* | |
* 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 |