How do I get the type of a value in Scheme?

前端 未结 4 1614
情话喂你
情话喂你 2021-01-01 13:58

I want a function that gets the type of a value at runtime. Example use:

(get-type a)

where a has been defined t

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 14:39

    In Racket, you can use the describe package by Doug Williams from PLaneT. It works like this:

    > (require (planet williams/describe/describe))
    > (variant (λ (x) x))
    'procedure
    > (describe #\a)
    #\a is the character whose code-point number is 97(#x61) and
    general category is ’ll (letter, lowercase)
    

提交回复
热议问题