如何检查返回的项目是否为列表本身? [英] How to check if an item returned is a list itself?
本文介绍了如何检查返回的项目是否为列表本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早晨-
我正在尝试查看是否有一种方法可以检查从列表返回的项目是否为列表本身.
I'm trying to see if there is a way to check if an item returned from a list is a list itself.
例如
(elt '(a (b c) d) 1)
是否可以检查返回的商品是否为列表?
Is there a way to check that the item returned is a list?
我尝试使用长度
(length (elt '(a (b c) d) 1))
但是,如果给它一个不是列表的项目,则会引发错误.
but if it is given an item that is not a list it throws an error.
简而言之,我正在寻找一种遍历列表中每个元素并检查它是否为列表的方法.
In short I'm looking for a way to go through each element of a list and check if it is a list or not.
谢谢
推荐答案
listp告诉您:
(listp (elt '(a (b c) d) 1))
这篇关于如何检查返回的项目是否为列表本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文