pair은
'(key value)
보통은 이렇게 쓰는 리스트
(pair? the-pair) =>
(not (cdr (cdr the-pair)))
주어진 리스트가 pair인지 확인
(pair the-pair) =>
(car (cdr the-pair))
pair자료형의 pair부분 즉 value값을 가져옴
(pair-key the-pair) =>
(car the-pair)
pair자료형의 key값
(list pair1 pair2 pair3 ...)
이런식으로 딕셔너리나 맵 비슷한 것을 만들 수 있음. 그냥 pairlist라 부름
(pairlist-pair the-pairlist key) =>
(cond ((not the-pairlist) nil)
((eq (pair-key (car the-pairlist)) key) (car the-pairlist))
(t (pairlist-pair (cdr the-pairlist) key)))
pairlist에서 key에 해당하는 pair을 가져옴
당연히 list-ref 구현처럼 성능같은 건 신경쓰지 않음 (못함)
scheme