Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rec ins z = function
- | [] -> [[z]]
- | x::xs ->
- let res = ins z xs
- let res1 = List.map (fun t -> x::t) res
- (z::x::xs)::res1
- let rec ins z = function
- | [] -> [[z]]
- | x::xs as L ->
- (z::L)::(List.map (fun t -> x::t) (ins z xs))
- ins 0 [1;2;3]
- let rec perm = function
- | [] -> [[]]
- | x::xs ->
- let res = perm xs
- res |> List.map (fun t -> ins x t) |> List.concat
- let rec perm = function
- | [] -> [[]]
- | x::xs ->
- perm xs |> List.collect (fun t -> ins x t)
- perm [1;2;3]
- let fact n = List.length(perm [1..n])
- fact 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement