7

Pythonではdir()を使用でき、ラケット(5.2)では実行できます

 (require xrepl)
 ,apropos

定義されたすべての変数のリストを取得します。すべてのスキームで同じことを行うための移植可能な方法は何ですか? これで、すべてのシステム変数とモジュール変数を除外するにはどうすればよいでしょうか? 変数の完全なリストは、ラケットではかなり困難です。

4

2 に答える 2

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 ())))
于 2012-06-05T13:56:29.420 に答える
4

まあ、これがガイルでそれを行う方法です(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)>>
...
于 2012-06-14T12:15:00.083 に答える