들어가며

🚧 사이트 공사중입니다.

Ref

아톰

(atom 1)
;;=>  T

(atom 'atom)
;;=>  T

(atom nil)
;;=>  T

Cons

s-expression

cons cell

car cdr

cons가 아닌 것은 아톰

(atom (cons 1 2))
;;=>  NIL
(consp '())
;;=> NIL

(consp '(1))
;;=> T

(consp '(1 . 2))
;;=> T

(consp '(1 2))
;;=> T
(type-of '())
;;=> NULL
(typep '() 'atom)
;;=> T

(type-of '(1))
;;=> CONS


(typep '() 'cons)
;;=> NIL
(typep '() 'list)
;;=> T

(typep '(1) 'cons)
;;=> T
(typep '(1) 'list)
;;=> T

(typep '(1 . 2) 'cons)
;;=> T
(typep '(1 . 2) 'list)
;;=> T

짚고 넘어가기

  • car / cdr
  • first / rest
  • cons
  • `consp

표현식

심볼

주석

함수

재귀

values

return

람다

조건문

비교

데이터 타입

1 1.1 1234567890123456789012345678901234567890123456789012345678901234567890 #C(1.2 3) ; 1.2 + 3i

type-of
cons
null
symbol
condition
function
sequence
array
vector
bit-vector
hash-table
stream
integer
float
number
short-float
single-float
double-float
long-float
complex
ratio
rational
string
character
random-state
package
pathname
readtable
restart

array atom bignum bit bit-vector chracter [common] compiled-function complex cons double-float fixnum float function hash-table integer keyword list long-float nil null number package pathname random-state ratio rational readtable sequence short-float signed-byte simple-array simple-bit-vector simple-string simple-vector single-float standard-char stream string [string-char] symbol t unsigned-byte vector

typep subtypep type-of

make-random-state
random-staterandom-state 복사
nil (기본값)현재 random-state 복사
t새로운 random-state
Common Lisp
(logand a b c)a & b & c
(logior a b c)a | b | c
(lognot a)~a
(logxor a b c)a ^ b ^ c
(ash a 3)a << 3
(ash a -3)a >> 3

log: bit-wise logical operations ash: arithmetic shift operation

https://www.lispworks.com/documentation/lw70/CLHS/Body/f_logand.htm

숫자

Integers Ratios 분수 Floating-Point Numbers Complex Numbers

integer fixnum bignum ratio ratio, rational, real, number, t

float #C(a b) #\char

most-positive-fixnum most-negative-fixnum

진법
2진법#bbinary
8진법#ooctal
16진법#xhexadecimal
N진법#Nr여기서 N은 임의의 수
부동 소수점
sshort-float
fsingle-float
ddouble-float
llong-float

복소수

a + bi == (complex a b) == #C(a b)

(type-of #C(1 2))
;;=> (COMPLEX (INTEGER 1 2))

(typep #C(1 2) 'complex)
;;=> T

(complex 1 2)
;;=> #C(1 2)

(* #C(1 2) #C(1 2))
;;=> #C(-3 4)

(complexp #C(1 2))
;;=> T

1+ 1- incf decf min max minusp / zerop / plusp evenp / oddp

LOG EXP EXPT SIN/COS/TAN ASIN/ACOS/ATAN 쌍곡선 함수: SINH, COSH, 및 TANH ASINH, ACOSH, 및 ATANH.

FLOOR CEILING TRUNCATE ROUND MOD REM

isqrt, which returns the greatest integer less than or equal to the exact positive square root of natural. gcd Greatest Common Denominator lcm Least Common Multiple.

Ref

불리언

문자

CHAR= 대소문자 구분 CHAR-EQUAL 대소문자 구분 x

Numeric AnalogCase-SensitiveCase-Insensitive
=CHAR=CHAR-EQUAL
/=CHAR/=CHAR-NOT-EQUAL
<CHAR<CHAR-LESSP
>CHAR>CHAR-GREATERP
<=CHAR<=CHAR-NOT-GREATERP
>=CHAR>=CHAR-NOT-LESSP

Ref

문자열

Numeric AnalogCase-SensitiveCase-Insensitive
=STRING=STRING-EQUAL
/=STRING/=STRING-NOT-EQUAL
<STRING<STRING-LESSP
>STRING>STRING-GREATERP
<=STRING<=STRING-NOT-GREATERP
>=STRING>=STRING-NOT-LESSP

:start1 :end1 :start2 :end2

(string= "foobarbaz" "quuxbarfoo" :start1 3 :end1 6 :start2 4 :end2 7)

배열

(defparameter *array* (make-array '(2 4) :initial-element 0))
;;=> *ARRAY*

*array*
;; => #2A((0 0 0 0) (0 0 0 0))

(aref *array* 0 0)
;; => 0

(setf (aref *array* 0 0) 100)
;; => 100

*array*
;; => #2A((100 0 0 0) (0 0 0 0))

(setf (aref *array* 1 1) 100)
;; => 100

*array*
;; => #2A((100 0 0 0) (0 100 0 0))

벡터

해시테이블

구조체

(defstruct Hello
  a
  b)

(make-Hello :a 1 :b 2)

;; :conc-name

짚고 넘어가기

  • defstruct
  • make-Blabla

map

print

(setq a '(1 2 3 4 5 6))
;;=> (1 2 3 4 5 6)

(dotimes (i 7)
  (let ((*print-length* i))
    (format t "~&~D -- ~S~%" i a)))
;;>> 0 -- (...)
;;>> 1 -- (1 ...)
;;>> 2 -- (1 2 ...)
;;>> 3 -- (1 2 3 ...)
;;>> 4 -- (1 2 3 4 ...)
;;>> 5 -- (1 2 3 4 5 ...)
;;>> 6 -- (1 2 3 4 5 6)
;;=> NIL

파일 입출력

바인드

패키지

타입 part2

에러

매크로

gensym

디버그

asdf

CLOS

커먼리스프 역사

인물들

John McCarthy

리더매크로

심볼매크로

Loop

Format

Quicklisp

참고자료