Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Problem with Comparator
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Teemu Antti-Poika  
View profile  
 More options Jun 22 2008, 4:19 pm
From: Teemu Antti-Poika <antti...@gmail.com>
Date: Sun, 22 Jun 2008 13:19:07 -0700 (PDT)
Local: Sun, Jun 22 2008 4:19 pm
Subject: Problem with Comparator
Hi folks,

I've just discovered Clojure (interesting stuff! Congrats!) and run
into something I could not figure out on my own. Here's a minimal
version of the problem:

(defn my-comparator [r1 r2]
  (if (< r1 r2)
    -1
    (if (= r1 r2)
      0
      1)))

(sort '(1 6 5 4) my-comparator)

In REPL this results in:
user=> java.lang.IncompatibleClassChangeError
java.lang.IncompatibleClassChangeError
        at clojure.fns.clojure.sort__669.invoke(boot.clj:1266)
        at clojure.lang.AFn.applyToHelper(AFn.java:186)
        at clojure.lang.AFn.applyTo(AFn.java:175)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2569)
        at clojure.lang.Compiler.eval(Compiler.java:3780)
        at clojure.lang.Repl.main(Repl.java:75)

What's this about? Any ideas?

My version of clojure jar is the latest on sourceforge (at the time of
writing).


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
 More options Jun 22 2008, 4:25 pm
From: Rich Hickey <richhic...@gmail.com>
Date: Sun, 22 Jun 2008 13:25:12 -0700 (PDT)
Local: Sun, Jun 22 2008 4:25 pm
Subject: Re: Problem with Comparator

On Jun 22, 4:19 pm, Teemu Antti-Poika <antti...@gmail.com> wrote:

The comparator goes first:

(sort my-comparator '(1 6 5 4))
-> (1 4 5 6)

Rich


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teemu Antti-Poika  
View profile  
 More options Jun 23 2008, 12:58 am
From: Teemu Antti-Poika <antti...@gmail.com>
Date: Sun, 22 Jun 2008 21:58:09 -0700 (PDT)
Local: Mon, Jun 23 2008 12:58 am
Subject: Re: Problem with Comparator
On Jun 22, 11:25 pm, Rich Hickey <richhic...@gmail.com> wrote:

> On Jun 22, 4:19 pm, Teemu Antti-Poika <antti...@gmail.com> wrote:

> > (sort '(1 6 5 4) my-comparator)

> > In REPL this results in:
> > user=> java.lang.IncompatibleClassChangeError
> > java.lang.IncompatibleClassChangeError

> The comparator goes first:

> (sort my-comparator '(1 6 5 4))
> -> (1 4 5 6)

> Rich

And so it seems to go - my bad!

Sorry to waste your time with that one, but thanks! :)

Teemu


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google