1. 배열 만들기
;; array 만들기 #()
;; (make-array n(크기) :initial-element n(n으로 초기화))
;; (make-array 3 :initial-element 1) => (1 1 1)
;; 인덱스 접근 : aref
;; (aref myarray 0)
;; (setf 배열이름 '#(a b c)) <<이런식으로도 선언가능
;; > (length "Cocktail") => 8
;; > (aref "Cocktail" 7) => #\l
;; > (type-of #\l) => CHARACTER
;; > (setf drink "Cocktail") => "Cocktail"
;; > (setf (aref drink 1) #\a) => #\a
;; > drink => "Cacktail"
;; hash table(해시 테이블)
;; > (setf h (make-hash-table))
;; gethash ? 해시테이블의 키값을 가져옴
;; (setf (get 'fred 'sex) 'male) =>male
;; (setf (get 'fred 'age) 23) => 23
;; Get: 심볼의 속성을 가져옴
;; Garbage colloection: getting more memory
;; COERCE: 타입을 바꿔즘 > (coerce '(#\b #\i #\r #\d) 'string)
;; MAP: working on sequences of any type (a general mapping function) 맵핑시킴
;; 저걸 쓰는 이유는 데이터 타입이 다를 때 유용 (mapcar는 안됨)
;; (map nil #'print "a b") 결과의 타입을 지정하지 않음
'Major > Lisp' 카테고리의 다른 글
[Lisp] Tic-Tac-Toe 게임 실습(2) (0) | 2021.06.09 |
---|---|
[Lisp] Chapter 12 구조체(Structures) (0) | 2021.06.09 |
[Lisp] Tic-Tac-Toe 게임 실습(1) (0) | 2021.06.09 |
[Lisp] Chapter 10 Assignment (0) | 2021.06.09 |
[Lisp] Ch 9 - Input/Output (0) | 2021.06.01 |