Skip to content

Instantly share code, notes, and snippets.

@kristof-mattei
Created October 6, 2015 19:34
Show Gist options
  • Save kristof-mattei/f6dfc249f13781f73a32 to your computer and use it in GitHub Desktop.
Save kristof-mattei/f6dfc249f13781f73a32 to your computer and use it in GitHub Desktop.
module Engine.Functions
let rec Calculate columns =
match columns with
| h::[] -> [ [ h ] ]
| h::t ->
let x = Calculate t
List.fold (fun acc elem -> (h::elem)::acc) ([h]::x) x
| [] -> []
let result = Calculate ["A"; "B"; "C"]
List.iter (fun x -> (printfn "%s" (List.fold (+) "" x))) result
(*
Gives
AC
AB
ABC
A
BC
B
C
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment