simple list?
Author Message
simple list?

What adjective describes a list whose elements are only atoms,
no lists ?  TIA

Thu, 22 Nov 2001 03:00:00 GMT
simple list?

Quote:

> What adjective describes a list whose elements are only atoms,
> no lists ?  TIA

(every #'atom <some-list>)

There are a number of functions in lisp for manipulating lists, and what
you have requested is a predicate applied to a list, specifially a special
kind of reduction. There are many ways of expressing such operations in
lisp. You can test for the existence of a list member thus using iteration
(which would be the negation of the above):

(loop for item in <some-list>
thereis (listp item))

Sunil

Fri, 23 Nov 2001 03:00:00 GMT
simple list?

Quote:

> What adjective describes a list whose elements are only atoms,
> no lists ?  TIA

"of atoms".  It's postfix.

I suppose by abuse of English (why not? everyone else does...) you could
say an "atom list" just as people would probably say an "integer list"
or "package list" or "frob list".  Then again, any time you use such
terminology you risk ambiguity.  Consider that some people use the
term "string list" to mean "1,2,3" not ("1" "2" "3").  The latter the same
people would call a "list of strings".

Fri, 23 Nov 2001 03:00:00 GMT
simple list?

<
< > What adjective describes a list whose elements are only atoms,
< > no lists ?  TIA
<
< (every #'atom <some-list>)

If nil is considered the empty list you could use nlistp, probably
from maclisp - elisp has it defined. Tough to say since nil is used as
false and the empty list.

(defun nlistp (x) (and x (atom x)))

(every #'nlistp ...)

.

Fri, 23 Nov 2001 03:00:00 GMT
simple list?

Quote:

> What adjective describes a list whose elements are only atoms,
> no lists ?  TIA

There is a classic homework problem to "flatten" a list, so
perhaps the adjective should be "flat", i.e. a flat list?

Sat, 24 Nov 2001 03:00:00 GMT
simple list?

Quote:

> > What adjective describes a list whose elements are only atoms,
> > no lists ?  TIA

> There is a classic homework problem to "flatten" a list, so
> perhaps the adjective should be "flat", i.e. a flat list?

Sounds good to me.

Sat, 24 Nov 2001 03:00:00 GMT
simple list?

Quote:

> What adjective describes a list whose elements are only atoms,
> no lists ?  TIA

"boring"

Stig Hemmer,

Sat, 24 Nov 2001 03:00:00 GMT
simple list?
"Manfred Knemeyer" wrote

Quote:
> What adjective describes a list whose elements are only atoms,
> no lists ?  TIA

Thank you for the responses.
I will use "flat list", which has the advantage of being both
conceptually (visually) clear and the appropriate technical
phrase.

Sat, 24 Nov 2001 03:00:00 GMT

 Page 1 of 1 [ 8 post ]

Relevant Pages