在python中,我可以使用dir(),在球拍(5.2)中我可以使用
(require xrepl)
,apropos
获取所有已定义变量的列表。在所有方案中都有什么便携方法可以做同样的事情?完成后,如何过滤掉所有系统和模块变量?完整的变量列表在球拍中相当令人生畏。
答案 0 :(得分:6)
要获取Racket中特定模块导出的名称,请使用module->exports。对于其他实现,您需要在文档中查找。
> (module->exports 'racket/list)
'((0
(add-between ()) (append* ()) (append-map ())
(argmax ()) (argmin ()) (cons? ()) (count ())
(drop ()) (drop-right ()) (eighth ()) (empty ())
(empty? ()) (fifth ()) (filter-map ())
(filter-not ()) (first ()) (flatten ())
(fourth ()) (last ()) (last-pair ())
(make-list ()) (ninth ()) (partition ())
(range ()) (rest ()) (second ())
(seventh ()) (shuffle ()) (sixth ())
(split-at ()) (split-at-right ()) (take ())
(take-right ()) (tenth ()) (third ())))
'((0 (remove-duplicates ())))
答案 1 :(得分:2)
嗯,这是如何在guile(v。> = 2.0)中执行此操作:
scheme@(guile-user)> ,binding
%module-public-interface #<variable 9e55e98 value: #<interface (guile-user) 9df6678>>
scheme@(guile-user)> (define foo 'bar)
scheme@(guile-user)> ,binding
foo #<variable a06fe28 value: bar>
%module-public-interface #<variable 9e55e98 value: #<interface (guile-user) 9df6678>>
您可以更改上下文以获取某些模块导出的绑定:
scheme@(guile-user)> (use-modules (srfi srfi-1))
scheme@(guile-user)> ,module (srfi srfi-1)
scheme@(srfi srfi-1)> ,binding
reduce-right #<variable 9ead2d0 value: #<procedure reduce-right (f ridentity lst)>>
delete #<variable 9eb7aa8 value: #<procedure delete (_ _ #:optional _)>>
lset-xor! #<variable 9eb7c90 value: #<procedure lset-xor! (= . rest)>>
take! #<variable 9ead640 value: #<procedure take! (lst i)>>
...