Computer Science/프로그래밍언어

OCaml Tutorial | Recursion with Lists

토마토. 2022. 3. 8. 19:11

let y : int list = [1;2;3];;
let rec length_of_list (l:int list) : int =
        begin match l with
        | [] -> 0
        | h::t -> 1 + ((length_of_list t))
        end;;
print_int (length_of_list y)

rec 가 recursion이라는 뜻임?