1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AutoLISP シンボル処理関数の使い方

Posted at

シンボル処理関数リファレンス(公式ヘルプ)

指定された項目がアトムかどうかを調べる atom

(atom 1)
;; -> T
(atom "a")
;; -> T
(atom 'a)
;; -> T
(atom "abc")
;; -> T
(atom '(1 2 3 4 5))
;; -> nil
(atom '("a" "b" "c" "d" "e"))
;; -> nil

現在定義されているシンボルのリストを返す atoms-family

(atoms-family 0)
;; -> (acToolbarDockBottom acet-var-setvar ・・・ C:SAVEALL)
(atoms-family 1)
;; -> ("ACTOOLBARDOCKBOTTOM" "ACET-VAR-SETVAR" ・・・ "C:SAVEALL")
(atoms-family 0 '("+" "-" "setq" "aaa" "princ"))
;; -> (+ - SETQ nil PRINC)
(atoms-family 1 '("+" "-" "setq" "aaa" "princ"))
;; -> ("+" "-" "SETQ" nil "PRINC")

シンボルに値が代入されているかどうかを調べる boundp

(setq val 1)
(boundp 'val)
;; -> T
(setq val nil)
(boundp 'val)
;; -> nil
(setq val 1)
(boundp val)
;; -> nil

指定された項目の評価が nil になるかどうかを調べる not

(not nil)
;; -> T
(not (< 1 2))
;; -> nil
(not (> 1 2))
;; -> T

指定された項目の内容が nil かどうかを調べる null

(null nil)
;; -> T
(null (< 1 2))
;; -> nil
(null (> 1 2))
;; -> T

指定された項目が実数または整数かどうかを調べる numberp

(numberp 1)
;; -> T
(numberp 1.5)
;; -> T
(numberp "a")
;; -> nil
(setq val 2.5)
(numberp val)
;; -> T
(numberp pi)
;; -> T

評価せずに式を返す quote

(quote a)
;; -> A
(quote +)
;; -> +

シングル クォーテーション付きのシンボル名の値に式を代入する set

(set 'a 123) ;;(setq a 123) と同じ
;; -> 123

シンボル(1 つまたは複数)に式の値を代入する setq

(setq a "aaa")
;; -> "aaa"
(setq b 123)
;; -> 123
;; まとめて代入
(setq c 123 d "aaa" e '("a" "b" "c"))
;; -> ("a" "b" "c")

指定された項目のタイプを返す type

(type 1)
;; -> INT
(type 1.0)
;; -> REAL
(type "abc")
;; -> STR
(type 'abc)
;; -> SYN
(type '+)
;; -> SYM
(type +)
;; -> SUBR
(type '(1 2 3 4 5))
;; -> LIST

シンボルの名前を含む文字列を返す vl-symbol-name

(vl-symbol-name 'a)
;; -> "A"
(vl-symbol-name 'abc)
;; -> "ABC"

シンボルに代入されている現在の値を返す vl-symbol-value

(setq val 1)
(vl-symbol-value 'val)
;; -> 1
(setq val "abc")
(vl-symbol-value 'val)
;; -> "abc"

指定されたオブジェクトがシンボルかどうかを調べる vl-symbolp

(vl-symbolp 'a)
;; -> T
(vl-symbolp 1)
;; -> nil
(vl-symbolp "a")
;; -> nil
(vl-symbolp +)
;; -> nil
(vl-symbolp '+)
;; -> T
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?