Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convention in Stdlib #3

Open
sangwoo-joh opened this issue Nov 17, 2020 · 0 comments
Open

Convention in Stdlib #3

sangwoo-joh opened this issue Nov 17, 2020 · 0 comments

Comments

@sangwoo-joh
Copy link
Owner

sangwoo-joh commented Nov 17, 2020

결론

  • Persistent는 담고 있는 타입부터 받고 (Set, Map) Imperative는 컨테이너 타입부터 받는다 (Array, Hashtbl)
  • 근데 또 Imperative인 Stack, Queue는 Persistent랑 비슷하다. 😰

List

  • 생성자: 개수 (int) -> 초기화 함수 (int -> 'a)
  • Iterators: ('a -> 'b) -> 'a list, fold의 경우 순서에 따라 ('a -> 'b -> 'a) -> 'a -> 'b list (left) 또는 ('a -> 'b -> 'b) -> 'a list -> 'b (right)

Array

  • get, set, length 류: 'a array 부터 받음
  • 생성자: 개수 (int) -> 초기값 'a
  • Iterators: ('a -> 'b) -> 'a array, fold의 경우 순서에 따라 ('a -> 'b -> 'a) -> 'a -> 'b array (left) 또는 ('a -> 'b -> 'b) -> 'a array -> 'b (right)

Hashtbl

  • add, find, mem, remove 등: ('a, 'b) t 부터 받고 이후 'a를 받음
  • 생성자: 개수 (int)
  • Iterators: ('a -> 'b -> 'c), fold는 ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c

Stack

  • push: 'a 부터

Queue

  • push: 'a 부터

Set

  • add, mem, find, remove 등: elt 부터
  • Iterators: (elt -> 'a) -> t, fold는 항상 increasing order로 (elt -> 'a -> 'a) -> t -> 'a

Map

  • add, update, mem, find, remove 등: key 부터 받고 필요하다면 이후에 'a
  • Iterators: (key -> 'a -> 'b), fold는 항상 increasing order로 (key -> 'a -> 'b -> 'b) -> 'a t -> 'b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant