epicours/Algo/Courses/Chapter 6 - Lists (Exercises).md

227 B

1.1 - Product

let rec product = function
	| [] -> 0
	| x::t -> x + product t;;

1.2 - Count

let rec count x n =
	if x = [] then
		0
	else
		let e::t = x
		if e = x then
			1 + count t n
		else
			count t n