OCaml version 4.08.1
# [1;2;3];;
- : int list = [1; 2; 3]
# [];;
- : 'a list = []
# [1];;
- : int list = [1]
# ["hi";"j
^CInterrupted.
# ["hi
^CInterrupted.
# ["a";"b";"c"];;
- : string list = ["a"; "b"; "c"]
# [1.2;3.2];;
- : float list = [1.2; 3.2]
#
선언은 이렇게
# let x : int list = [2;3;4];;
val x : int list = [2; 3; 4]
# let x = [2;3;4];;
val x : int list = [2; 3; 4]
let y = [1;2;3];;
let is_list_empty (1:int list):int =
begin match 1 with
| [] -> 1
| h::t -> 0
end;;
print_int (is_list_empty y);;
'Computer Science > 프로그래밍언어' 카테고리의 다른 글
OCaml 함수 예제 (0) | 2022.03.09 |
---|---|
OCaml Tutorial | Recursion with Lists (0) | 2022.03.08 |
OCaml Tutorial | Introduction to Pattern Matching (0) | 2022.03.08 |
OCaml Tutorial | Introduction to Functions (0) | 2022.03.08 |
OCaml Tutorial | Introduction to Variables (0) | 2022.03.08 |