Arc Forumnew | comments | leaders | submitlogin
1 point by waterhouse 5081 days ago | link | parent

Macro: (aps x) : Returns a list of all bound Arc symbols for which x (coerced to a string) is a substring of the symbol (coerced to a string). Come to think of it, I'll make it sort them, too. Extremely useful if you wonder what precisely a function was named, or whether certain functions exist.

  arc> aps.map
  (deep-map map map-chooses map-more map-subperms map1 mapn mappend maptable s-map s-map1)
Implementing this requires access to the underlying Racket (or something similar in non-Racket Arc implementations). If, as in Anarki, ($ expr) causes expr to pass straight through the Arc compiler into underlying Racket, then the following implementation will work:

  (def arc-namespace ()
    (map [sym:cut string._ 1]
         (keep [is string._.0 #\_]
               ($.namespace-mapped-symbols))))
  (def apropos-fn (x)
    (sort < (map sym (keep [findsubseq x _]
                           (map string (arc-namespace))))))
  (mac aps (x) `(apropos-fn (string ',x)))
See also: http://arclanguage.org/item?id=11468

For hacking ac.scm to make '$ work, see http://arclanguage.org/item?id=8719 and use '$ instead of 'mz.



1 point by fallintothis 5081 days ago | link

I remember that thread! Good stuff.

Though it's more limited, you might even just use sig in vanilla Arc.

  (mac apropos (name)
    (list 'quote
           (sort (compare < string)
                 (keep [findsubseq (string name) (string _)] (keys sig)))))

-----