Test wether something is an atom (as it is known in Scheme)

422 views
Skip to first unread message

Arie van Wingerden

unread,
Dec 5, 2008, 8:07:22 AM12/5/08
to clo...@googlegroups.com
Hi,

I am learning Clojure by working thru Kent Dybvigs book in Scheme and Clojure at the same time. A nice way to discover the differences ;-)

I wonder if the next definition is appropriate to test if something ia an atom (as Scheme sees it):

(defn atom? [x]
      (not (coll? x)))

Thx,
   Arie

Mark McGranaghan

unread,
Dec 5, 2008, 8:50:53 AM12/5/08
to clo...@googlegroups.com
This is indeed the definition used in the clojure.contrib.pred library:
http://github.com/kevinoneill/clojure-contrib/tree/master/src/clojure/contrib/pred.clj#L45

- Mark M.

Stephen C. Gilardi

unread,
Dec 5, 2008, 9:03:22 AM12/5/08
to clo...@googlegroups.com

On Dec 5, 2008, at 8:50 AM, Mark McGranaghan wrote:

This is indeed the definition used in the clojure.contrib.pred library:
http://github.com/kevinoneill/clojure-contrib/tree/master/src/clojure/contrib/pred.clj#L45

That's true. However, with Clojure now having a specific meaning for  "atom" that's different from that of the larger Lisp world, I'm wondering if it would be a good idea to remove atom? from pred.clj.

Feedback welcome.

--Steve

Meikel Brandmeyer

unread,
Dec 5, 2008, 9:07:15 AM12/5/08
to Clojure
Hi,

On 5 Dez., 15:03, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> That's true. However, with Clojure now having a specific meaning for  
> "atom" that's different from that of the larger Lisp world, I'm  
> wondering if it would be a good idea to remove atom? from pred.clj.
>
> Feedback welcome.

I would think so. Or come up with a different name.
non-coll? ?

Sincerely
Meikel

Rich Hickey

unread,
Dec 5, 2008, 9:09:02 AM12/5/08
to Clojure


On Dec 5, 9:03 am, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> On Dec 5, 2008, at 8:50 AM, Mark McGranaghan wrote:
>
> > This is indeed the definition used in the clojure.contrib.pred
> > library:
> >http://github.com/kevinoneill/clojure-contrib/tree/master/src/clojure...
>
> That's true. However, with Clojure now having a specific meaning for
> "atom" that's different from that of the larger Lisp world, I'm
> wondering if it would be a good idea to remove atom? from pred.clj.
>
> Feedback welcome.
>

atom?/p is not one of strongest or best-named abstractions in older
Lisps. Maybe it made sense in a world with only one composite data
structure. Good riddance I say.

Rich

Arie van Wingerden

unread,
Dec 5, 2008, 10:24:52 AM12/5/08
to clo...@googlegroups.com
Hi Mark,

didn't know about that. But I'm glad it appears to be okay then.

Arie

2008/12/5 Mark McGranaghan <mmcg...@gmail.com>

Arie van Wingerden

unread,
Dec 5, 2008, 10:28:48 AM12/5/08
to clo...@googlegroups.com
Hi Rich,

right. But still I think Meikel has got a valid point that a function would need to be defined for that.

I also wondered whether a kind of  type? function would be appropriate.
So (type? 3) would return integer etc.

Arie

2008/12/5 Rich Hickey <richh...@gmail.com>

Rich Hickey

unread,
Dec 5, 2008, 10:53:10 AM12/5/08
to Clojure
We have complement and not. Do we need non-xxx? versions of all the
predicates? I don't think non-coll? is special.

Rich


Rich Hickey

unread,
Dec 5, 2008, 10:54:11 AM12/5/08
to Clojure


On Dec 5, 10:28 am, "Arie van Wingerden" <xapw...@gmail.com> wrote:
> Hi Rich,
>
> right. But still I think Meikel has got a valid point that a function would
> need to be defined for that.
>
> I also wondered whether a kind of type? function would be appropriate.
> So (type? 3) would return integer etc.
>

There is class, and, more useful, instance?

Rich

> 2008/12/5 Rich Hickey <richhic...@gmail.com>
Reply all
Reply to author
Forward
0 new messages