Ocaml Study
-
[Ocaml] 함수표현, Currying, if then else, recursive, inOcaml Study 2022. 4. 7. 00:37
Ocaml * Procedure Definitions - let = (let binding) # let x = 0;; val x : int = 0 # let s = "string";; val s : string = "string" # let b = true;; val b : bool = true # let x = 1+3;; *x에 식을 지정할 수 있다 val x : int = 4 # let add = (+);; *add에 +기능을 넣었다 val add : int -> int -> int = *int값 사용 제시 # add x 5;; *add x and 5 - : int = 9 # let mul = ( * );; *곱셈은 띄어쓰기 필수! # mul (add 1 (mul 2 3)) (add 4 5);; *띄..
-
[Ocaml] 기본 구조, 타입, 연산자Ocaml Study 2022. 3. 10. 01:35
OCaml - 표현력과 안전성에 중점을 둔 범용 프로그래밍 언어입니다. - 함수형 프로그래밍 언어입니다. 함수의 정의와 사용에 제한이 없습니다. - main이 없으며 let의 집합으로 구성된다. * 자동적으로 타입 결정 basic types: integers, floating point numbers, booleans, characters, strings. # 123;; - : int = 123 # "hello";; - : string = "hello" # true;; - : bool = true * Arithmetic operators (산술 연산자) int) + - * / mod float) +. -. *. /. ** # (+);; - : int -> int -> int = # (+) 1 2;; - ..