분류 전체보기 477

OCaml 함수 예제

알아야 하는 것 for문 함수 구조 타입 리스트 인덱싱 match with OCaml version 4.08.1 # let rec last = function | [] -> None | [x] -> Some x | _::t -> last t;; val last : 'a list -> 'a option = # last ["a";"b";"c";"d"];; - : string option = Some "d" # last [];; - : 'a option = None # # let rec last_two = function | [] | [_] -> None | [x;y] -> Some (x,y) | _::t -> last_two t;; val last_two : 'a list -> ('a * 'a) option..

OCaml Tutorial | Introduction to Lists

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_lis..

OCaml Tutorial | Introduction to Pattern Matching

let is_zero (x:int) : string = match x with | 0 -> "true" | 1 -> "false";; print_string (is_zero 0);; c언어의 case랑 비슷한 기능인 것 같음 @martini:~$ ocaml pattern.ml File "./pattern.ml", line 2, characters 8-81: 2 | ........match x with 3 | | 0 -> "true" 4 | | 1 -> "false".. Warning 8: this pattern-matching is not exhaustive. Here is an example of a case that is not matched: 2 true 이 에러 해결하려면, let is_zero ..

오픽노잼 | 오픽 공부법 2가지

step 1. MP 마스터하기 Main Point - 대화의 요점이 중요하다. - 체계적으로 대화할 수 있게 한다. - 대답을 짧게 말할 수 있다. - 오픽은 짧고 깔끔하게 말하는 것이 중요하다. - 질문이든 2분 내로 말할 수 있게 한다. - Main Point 공부하는 게 먼저 - 감을 잡기 위해서. 답을 짧게 대답하는 것. - Main Point에 대해서 이야기하는 것. - all about 무엇보다도 - MP 빨리 뱉어낼 수 있는지 연습 step 2. 질문 컨트롤하기 - Main point 빛나게 하는 방법 - General - Singular step 3. 녹음 중요 - 대화 시험

English 2022.03.02