Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

emacs lispでデータ型の種類を判定する

型を判定します。
型述語というそうです。

文字や文字列の類

objectが文字列か文字(つまり、整数)ならば tを返し、さもなければnilを返す。

(char-or-string-p "hoge")
t

(char-or-string-p 1)
t

数値

(integerp "hoge")
nil

(integerp 1)
t

文字列

(stringp "hoge")
t

(stringp 1)
nil

GNU Emacs Lispリファレンスマニュアル: Lispのデータ型