获取用户创建的变量列表 [英] Get list of user created variables

查看:86
本文介绍了获取用户创建的变量列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取我在lisp会话中创建的所有变量的列表.我认为应该可以通过查看common-lisp-user中的所有符号来实现.但是如何获得这样的列表?

I want to get a list of all variables that I have created in a lisp session. I think that this should be possible by looking at all symbols interned in common-lisp-user. But how can I get such a list?

推荐答案

要仅从cl-user获取绑定变量,请使用do-symbols迭代所有绑定符号,并排除从其他包中导入的符号:

To get bound variables only from cl-user you iterate all bound symbols with do-symbols and exclude the symbols, that are imported from other packages:

(let ((external-symbols (mapcan (lambda (pkg)
                                  (let (rez)
                                    (do-symbols (s pkg rez)
                                      (push s rez))))
                                (package-use-list (find-package 'cl-user)))))
  (do-symbols (s 'cl-user)
    (when (and (boundp s)
               (not (member s external-symbols)))
      (print s))))

这篇关于获取用户创建的变量列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆