LoginSignup
1
1

More than 5 years have passed since last update.

Gauche(Scheme)で値の型を調べるにはclass-of

Last updated at Posted at 2016-11-14
classof.scm
(print (class-of 123))
(print (class-of "hoge"))
(print (class-of 'moge))
(print (class-of #t))
(print (class-of '()))
(print (class-of '(1 2)))
(print (class-of (cons 'a 'b)))
(print (class-of ''a))
(print (class-of (quote (quote a))))
(print (class-of (number->string 123)))

;; 結果
#<class <integer>>
#<class <string>>
#<class <symbol>>
#<class <boolean>>
#<class <null>>
#<class <pair>>
#<class <pair>>
#<class <pair>>
#<class <pair>>
#<class <string>>

Racketなどの他の処理系の場合はこちらに書いてある:
http://stackoverflow.com/questions/11566886/how-do-i-get-the-type-of-a-value-in-scheme

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