From: smartnose
Subject: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <e21e07ae-a695-45df-8eff-234d4f99a632@q9g2000hsb.googlegroups.com>
I have two 2D integer arrays and I want to compare whether they are
exactly the same.

So far, I just wrote 2 loops to check that.

Is there any efficient routine that can help me deal with it?

Thanks.

W.

From: Barry Margolin
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <barmar-6C9A40.22422119102008@mara100-84.onlink.net>
In article 
<····································@q9g2000hsb.googlegroups.com>,
 smartnose <·········@gmail.com> wrote:

> I have two 2D integer arrays and I want to compare whether they are
> exactly the same.
> 
> So far, I just wrote 2 loops to check that.
> 
> Is there any efficient routine that can help me deal with it?

EQUALP works for arrays.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Pascal Bourguignon
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <48ff7287$0$1127$426a74cc@news.free.fr>
Barry Margolin wrote:
> In article 
> <····································@q9g2000hsb.googlegroups.com>,
>  smartnose <·········@gmail.com> wrote:
> 
>> I have two 2D integer arrays and I want to compare whether they are
>> exactly the same.
>>
>> So far, I just wrote 2 loops to check that.
>>
>> Is there any efficient routine that can help me deal with it?
> 
> EQUALP works for arrays.

The problem is that the OP didn't say what he meatn by "exactly the 
same".  (I'd tend to understand "exactly the same" as EQ).

Beside containing the same elements, arrays also have attributes such as 
  whether the array is adjustable, displaced, whether it has a fill 
pointer (in the case of 1D arrays), etc.

Does "exactly the same" means that these attributes have to be the same 
too or not?


Then, there's this little detail that EQUALP compares strings case 
insensitively, so (equalp #2A(("abc" "def") ("ghi" "klm"))  #2A(("ABC" 
"DEF") ("GHI" "KLM"))) --> T

-- 
__Pascal Bourguignon__
http://www.informatimago.com
From: Barry Margolin
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <barmar-51D223.23590822102008@mara100-84.onlink.net>
In article <························@news.free.fr>,
 Pascal Bourguignon <···@informatimago.com> wrote:

> Barry Margolin wrote:
> > In article 
> > <····································@q9g2000hsb.googlegroups.com>,
> >  smartnose <·········@gmail.com> wrote:
> > 
> >> I have two 2D integer arrays and I want to compare whether they are
> >> exactly the same.
> >>
> >> So far, I just wrote 2 loops to check that.
> >>
> >> Is there any efficient routine that can help me deal with it?
> > 
> > EQUALP works for arrays.
> 
> The problem is that the OP didn't say what he meatn by "exactly the 
> same".  (I'd tend to understand "exactly the same" as EQ).
> 
> Beside containing the same elements, arrays also have attributes such as 
>   whether the array is adjustable, displaced, whether it has a fill 
> pointer (in the case of 1D arrays), etc.
> 
> Does "exactly the same" means that these attributes have to be the same 
> too or not?

He said he's doing the comparison using two (nested, I assume) loops.  
EQUALP simply replaces those loops.  If he wants to perform other 
checks, he can still do them as well.

> 
> Then, there's this little detail that EQUALP compares strings case 
> insensitively, so (equalp #2A(("abc" "def") ("ghi" "klm"))  #2A(("ABC" 
> "DEF") ("GHI" "KLM"))) --> T

Good point.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Kenny
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <49001d05$0$4909$607ed4bc@cv.net>
Pascal Bourguignon wrote:
> Barry Margolin wrote:
> 
>> In article 
>> <····································@q9g2000hsb.googlegroups.com>,
>>  smartnose <·········@gmail.com> wrote:
>>
>>> I have two 2D integer arrays and I want to compare whether they are
>>> exactly the same.
>>>
>>> So far, I just wrote 2 loops to check that.
>>>
>>> Is there any efficient routine that can help me deal with it?
>>
>>
>> EQUALP works for arrays.
> 
> 
> The problem is that the OP didn't say what he meatn by "exactly the 
> same".  (I'd tend to understand "exactly the same" as EQ).

Nonsense. Why specify the add-on requirement exactly if one means EQ? 
And the OP said they had two arrays (not two array references), so we 
already know they are not EQ-same.

Do I have tot teach you people how to read, too?!!!!

> 
> Beside containing the same elements, arrays also have attributes such as 
>  whether the array is adjustable, displaced, whether it has a fill 
> pointer (in the case of 1D arrays), etc.
> 
> Does "exactly the same" means that these attributes have to be the same 
> too or not?


Looking for a smiley face desperately hoping you are joking....uh-oh.

:)

> 
> 
> Then, there's this little detail that EQUALP compares strings case 
> insensitively, so (equalp #2A(("abc" "def") ("ghi" "klm"))  #2A(("ABC" 
> "DEF") ("GHI" "KLM"))) --> T
> 

Right. And is "donut" the same as "donut" is the first something one 
eats in the morning and the second is something a hot rod does spinning 
round and round on someone's lawn?

hth,kzo
From: Pascal Bourguignon
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <490089af$0$6027$426a74cc@news.free.fr>
Kenny wrote:
> Pascal Bourguignon wrote:
>> Barry Margolin wrote:
>>
>>> In article 
>>> <····································@q9g2000hsb.googlegroups.com>,
>>>  smartnose <·········@gmail.com> wrote:
>>>
>>>> I have two 2D integer arrays and I want to compare whether they are
>>>> exactly the same.
>>>>
>>>> So far, I just wrote 2 loops to check that.
>>>>
>>>> Is there any efficient routine that can help me deal with it?
>>>
>>>
>>> EQUALP works for arrays.
>>
>>
>> The problem is that the OP didn't say what he meatn by "exactly the 
>> same".  (I'd tend to understand "exactly the same" as EQ).
> 
> Nonsense. Why specify the add-on requirement exactly if one means EQ? 
> And the OP said they had two arrays (not two array references), so we 
> already know they are not EQ-same.
> 
> Do I have tot teach you people how to read, too?!!!!
> 
>>
>> Beside containing the same elements, arrays also have attributes such 
>> as  whether the array is adjustable, displaced, whether it has a fill 
>> pointer (in the case of 1D arrays), etc.
>>
>> Does "exactly the same" means that these attributes have to be the 
>> same too or not?
> 
> 
> Looking for a smiley face desperately hoping you are joking....uh-oh.
> 
> :)

No, I'm not joking.  I find that posing ("thinking"!) this kind of 
questions in some formal language (mathematics or programming) is less 
error-prone than trying to use informal and ambiguous languages such as 
human languages.  And English is not well placed on this topic.


Of course, once you've posed the question in a formal language, the 
answer is generally obvious...



-- 
__Pascal Bourguignon__
http://www.informatimago.com
From: George Neuner
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <42u2g45vaof9g6ftqnh5348s2d1t35cti3@4ax.com>
On Thu, 23 Oct 2008 02:42:38 -0400, Kenny <·········@gmail.com> wrote:

>
>Right. And is "donut" the same as "donut" is the first something one 
>eats in the morning and the second is something a hot rod does spinning 
>round and round on someone's lawn?

No.  The food is a _dough_nut. The lawn marking is a donut and the
fool driving the hot rod is a _doh_nut.

George
From: Kenny
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <49017d0e$0$5638$607ed4bc@cv.net>
George Neuner wrote:
> On Thu, 23 Oct 2008 02:42:38 -0400, Kenny <·········@gmail.com> wrote:
> 
> 
>>Right. And is "donut" the same as "donut" is the first something one 
>>eats in the morning and the second is something a hot rod does spinning 
>>round and round on someone's lawn?
> 
> 
> No.  The food is a _dough_nut.

Joe Six-Pack wuld like a word with you.

> The lawn marking is a donut and the
> fool driving the hot rod is a _doh_nut.

That helps.

kt
From: Tamas K Papp
Subject: Re: How to compare 2 2D Array in lisp?
Date: 
Message-ID: <6m26v5Fepdi3U1@mid.individual.net>
On Sun, 19 Oct 2008 18:38:50 -0700, smartnose wrote:

> I have two 2D integer arrays and I want to compare whether they are
> exactly the same.
> 
> So far, I just wrote 2 loops to check that.

That's the way to do it.  Or if you want to be fancier, you can use row-
major-aref to retrieve the elements, it is supposed to be slightly faster.

> Is there any efficient routine that can help me deal with it?

You can make your own routine very efficient.

Tamas