let xs = 1 :: 2 :: 3 :: 4 :: [];;
let rec nTy = function (xs, n) ->
if (xs = []) then raise (Failure "Error")
else if (n = 1) then List.hd xs
else nTy(List.tl xs, n - 1);;
nTy(xs, 2);;
let rec podzielPoN = function (xs, n) ->
let rec podzielPoN_it = function (a, b, n) ->
if (n = 0) then (b, a)
else podzielPoN_it(List.tl a, b @ (List.hd a :: []), n - 1)
in podzielPoN_it(xs, [], n);;
podzielPoN (xs, 2)
let rec podzielWgMod = function (xs, n) ->
let rec podzielWgMod_it = function (xs, a, b) ->
if (xs = []) then (a, b)
else if (List.hd xs mod n = 0) then podzielWgMod_it(List.tl xs, a @ (List.hd xs :: []), b)
else podzielWgMod_it(List.tl xs, a, b @ (List.hd xs :: []))
in podzielWgMod_it(xs, [], []);;
podzielWgMod(xs, 2);;
let rec coNTy = function (xs, n) ->
let rec coNTy_it = function (x, i) ->
if (x = []) then []
else if (i = 1) then List.hd x :: coNTy_it(List.tl x, n)
else coNTy_it(List.tl x, i - 1)
in coNTy_it(xs, n);;
coNTy(xs, 2);;