How to check if an item returned is a list itself?

对着背影说爱祢 提交于 2019-12-11 10:32:20

问题


Morning -

I'm trying to see if there is a way to check if an item returned from a list is a list itself.

For example

(elt '(a (b c) d) 1)

Is there a way to check that the item returned is a list?

I tried using length,

(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.

Thank you


回答1:


the listp tells you that :

(listp (elt '(a (b c) d) 1))


来源:https://stackoverflow.com/questions/12512143/how-to-check-if-an-item-returned-is-a-list-itself

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!