printf "==========\nQuestion 1\n==========\n"
let pos = List.filter (fun x -> x > 0) list
let cubed = List.map (fun x -> x * x * x) pos
for i in 0 .. pos.Length - 1 do
printf "%d Cubed: %d\n" (pos.Item(i)) (cubed.Item(i))
printf "\n==========\nQuestion 2\n==========\n"
| n when n = bigint 1 -> bigint 1
| _ -> n * Fact(n - bigint 1)
(Fact X) / ((Fact Y) * (Fact (X - Y)))
printf "C 20 5 = %A\n" res
printf "\n==========\nQuestion 3\n==========\n"
List.map2 (+) list1 list2
printf "vecadd [1;2;3] [4;5;6]\nResult List: %A\n" (vecadd [1;2;3] [4;5;6])
printf "\nvecadd [1;2;-3;4] [4;-5;6;7]\nResult List: %A\n" (vecadd [1;2;-3;4] [4;-5;6;7])
printf "\n==========\nQuestion 4\n==========\n"
List.map2 (fun x y -> vecadd x y) mat1 mat2
let m1 = [[1;4];[2;5];[3;6]]
let m2 = [[7;1];[8;2];[9;3]]
printf "Matrix 1: %A\n" m1
printf "Matrix 2: %A\n" m2
printf "M1 + M2: %A\n" m3