从列表LISP中删除NIL [英] Removing NIL's from a list LISP

查看:113
本文介绍了从列表LISP中删除NIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题.

说我的清单q中有一堆NIL.是否有一种简单的方法可以删除NIL并仅保留数字?评估似乎在这里不起作用.

Say I have a bunch of NIL's in my list q . Is there a simple way to remove the NILs and just keep the numbers?. eval doesn't seem to work here.

(NIL 1 NIL 2 NIL 3 NIL 4)

我需要(1 2 3 4)

推荐答案

通用Lisp,而不是remove-如果可以使用remove:

Common Lisp, instead of remove-if you can use remove:

(remove nil '(nil 1 nil 2 nil 3 nil 4))

这篇关于从列表LISP中删除NIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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