英文:
Finding possible functions among the large number of "standard" common lisp functions?
问题
Is there a way to discover common lisp function(s) by searching via description of what the desired function does rather than searching on function names? It is frustrating to only be able to lookup functions by name, when what is really needed is an ability to go from descriptive information to possible candidate functions! Thanks.
英文:
Is there a way to discover common lisp function(s) by searching via description of what the desired function does rather than searching on function names? It is frustrating to only be able to lookup functions by name, when what is really needed is an ability to go from descriptive information to possible candidate functions! Thanks.
答案1
得分: 3
Quicklisp-apropos
这个新的库是几天前发布的:https://github.com/mmontone/quicklisp-apropos 它是slime-star的一部分,汇集了一些用于 Slime 的生活质量扩展。
要安装它,将其克隆到某个位置,安装依赖项:
(ql:quickload '(:dexador :chipz :archive :montezuma :string-case))
然后加载 quicklisp-apropos.lisp
文件(C-c C-k,load
…)。
该系统提供了一些函数:
quicklisp-apropos:apropos -f------ 480.57
quicklisp-apropos:apropos-doc -f------ 477.23
quicklisp-apropos:apropos-name -f------ 477.00
quicklisp-apropos:apropos-class -f------ 476.82
quicklisp-apropos:apropos-macro -f------ 476.82
quicklisp-apropos:apropos-system -f------ 476.68
quicklisp-apropos:apropos-package -f------ 476.57
quicklisp-apropos:apropos-function -f------ 476.48
quicklisp-apropos:apropos-variable -f------ 476.48
quicklisp-apropos:apropos-generic-function -f------ 476.09
在文档字符串中搜索
CL-USER> (quicklisp-apropos:apropos-doc "random")
50个结果:
--------------------------------------------------------------------------------
system random in system NIL
一些简单的随机数生成器。
random
======
ACM 随机数生成器
random
======
ACM 随机数生成器
--------------------------------------------------------------------------------
generic-function FL.MATLISP:FILL-RANDOM! in system femlisp-matlisp
用随机值(通过(random s)获得)填充X。
--------------------------------------------------------------------------------
class CL-RRT:RRT-TREE-NODE in system cl-rrt
随机树的节点类。
--------------------------------------------------------------------------------
function STDUTILS:SEED-RANDOM-GENERATOR in system stdutils
评估随机数量的项目
--------------------------------------------------------------------------------
function STATISTICS:RANDOM-SEED in system scigraph
返回一个随机种子。
[…]
这会在所有 Quicklisp 的库上进行搜索(它在第一次使用时会下载索引的缓存)。
Ultralisp
Ultralisp 也维护着一个索引,允许按函数名称和文档进行搜索。
https://ultralisp.org/search/?query=random
我的最后一个想法是进行高级的 Github 代码搜索。
通过搜索所需函数的描述
如果您考虑根据类型或示例(à la Smalltalk)进行搜索,我不知道这样的功能。
英文:
Quicklisp-apropos
This new library was published a few days ago: https://github.com/mmontone/quicklisp-apropos It is part of slime-star, regrouping several quality-of-life extensions for Slime.
To install, clone it somewhere, install the dependencies:
(ql:quickload '(:dexador :chipz :archive :montezuma :string-case))
and load the quicklisp-apropos.lisp
file (C-c C-k, load
…).
The system provides a few functions:
quicklisp-apropos:apropos -f------ 480.57
quicklisp-apropos:apropos-doc -f------ 477.23
quicklisp-apropos:apropos-name -f------ 477.00
quicklisp-apropos:apropos-class -f------ 476.82
quicklisp-apropos:apropos-macro -f------ 476.82
quicklisp-apropos:apropos-system -f------ 476.68
quicklisp-apropos:apropos-package -f------ 476.57
quicklisp-apropos:apropos-function -f------ 476.48
quicklisp-apropos:apropos-variable -f------ 476.48
quicklisp-apropos:apropos-generic-function -f------ 476.09
Search in the docstrings
CL-USER> (quicklisp-apropos:apropos-doc "random")
50 results:
--------------------------------------------------------------------------------
system random in system NIL
Some simple random number generators.
random
======
ACM random number generator
random
======
ACM random number generator
--------------------------------------------------------------------------------
generic-function FL.MATLISP:FILL-RANDOM! in system femlisp-matlisp
Fills X with random values (obtained by (random s)).
--------------------------------------------------------------------------------
class CL-RRT:RRT-TREE-NODE in system cl-rrt
Node class of Random Tree.
--------------------------------------------------------------------------------
function STDUTILS:SEED-RANDOM-GENERATOR in system stdutils
Evaluate a random number of items
--------------------------------------------------------------------------------
function STATISTICS:RANDOM-SEED in system scigraph
Return a random seed.
[…]
This searches on all Quicklisp's libraries (it downloads a cache of the index at first use).
Ultralisp
Ultralisp also maintains an index, allowing to search by function names and documentation.
https://ultralisp.org/search/?query=random
My last idea would be an advanced Github code search.
> by searching via description of what the desired function does
if you are thinking search based on types or on example à la Smalltalk, I don't know such things.
答案2
得分: 0
I have a library that does what you describe for either the standard library or for a selection of external libraries. It is lib-helper, found here: https://github.com/albuspiroglu/cl-lib-helper or quicklisp: (ql:quickload "lib-helper")
For example to find any (or replace the .* with the regexp of symbol name to filter further) symbol with the word "structure" in its descriptions:
;; to search only in standard library:
(std:find-syms '(".*" "structure"))
;; or
(std:find-syms ".* structure")
;; to search in custom libraries along with std:
(lib:find-syms '(".*" "structure"))
;;or
(lib:find-syms ".* structure")
I made the word descriptions bold above, to point out the detail that the documentation for objects are searched not only for variable namespace, but other namespaces as well. So find-syms will search the documentation created by:
(defun foo ()
"this documentation string"
(print "hello"))
;; or:
(defgeneric foo ()
(:documentation "this string"))
;; or:
(defclass ()
((a :documentation "here as well")))
(:documentation "or this class documentation"))
;; or
(defvar var1 nil "this documentation as well")
;; etc.
There are some other features in the library, such as helping with grouping functions in hierarchies, listing all functions within a hierarchy group, helping with drop-down search of functions, etc.
For a brief usage example screencast: https://youtu.be/NygQTvbkMjY
Edit1: I forgot to mention, that the search string is not only searched in descriptions, but also the "hierarchy-group" name that the symbol resides as well, helping with further narrowing down results.
Another helpful feature is, a class can be a last-element in the group hierarchy (instead of packages), and if that's the case it will have the list of its methods (the specific methods that act on that class) in its group, giving you the methods of the class, in a sense.
英文:
I have a library that does what you describe for either the standard library or for a selection of external libraries.
It is lib-helper, found here: https://github.com/albuspiroglu/cl-lib-helper
or quicklisp: (ql:quickload "lib-helper")
For example to find any (or replace the .* with the regexp of symbol name to filter further) symbol with the word "structure" in its descriptions:
;; to search only in standard library:
(std:find-syms '(".*" "structure"))
;; or
(std:find-syms ".* structure")
;; to search in custom libraries along with std:
(lib:find-syms '(".*" "structure"))
;;or
(lib:find-syms ".* structure")
I made the word descriptions bold above, to point out the detail that the documentation for objects are searched not only for variable namespace, but other namespaces as well. So find-syms will search the documentation created by:
(defun foo ()
"this documentation string"
(print "hello"))
;; or:
(defgeneric foo ()
(:documentation "this string"))
;; or:
(defclass ()
((a :documentation "here as well")))
(:documentation "or this class documentation"))
;; or
(defvar var1 nil "this documentation as well")
;; etc.
There are some other features in the library, such as helping with grouping functions in hierarchies, listing all functions within a hierarchy group, helping with drop-down search of functions, etc.
For a brief usage example screencast: https://youtu.be/NygQTvbkMjY
Edit1: I forgot to mention, that the search string is not only searched in descriptions, but also the "hierarchy-group" name that the symbol resides as well, helping with further narrowing down results.
Another helpful feature is, a class can be a last-element in the group hierarchy (instead of packages), and if that's the case it will have the list of its methods (the specific methods that act on that class) in its group, giving you the methods of the class, in a sense.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论