Freddy
Freddy

Reputation: 2279

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

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

Upvotes: 1

Views: 231

Answers (1)

meirrav
meirrav

Reputation: 771

the listp tells you that :

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

Upvotes: 9

Related Questions