/// intersperses the value c into the elements of the sequence s after every n elements of s /// e.g. intersperse -1 4 (seq{1..10}) will generate {1; 2; 3; 4; -1; 5; 6; 7; 8; -1; 9; 10;} let intersperse c s = let rec tail_intersperse c s acc = match s with | [] -> acc | [head] ->acc @ [head] | head::tail -> tail_intersperse c tail (acc @ [head;c]) tail_intersperse c s []