Thanks to Roger and Ross for suggestions. I also think that benchmark timing
will be slightly different if all items are in fact unique.
Any chance to make special code for *./@~: ?
Roger Hui wrote:
ts=: 6!:2 , 7!:[EMAIL PROTECTED]
x=: 1e6 [EMAIL PROTECTED] 1e6
y=: 1e5 2 5 [EMAIL PROTECTED] 10
x y
*./@~: 0.121303 2.09824e6 0.0421528 1.18099e6
i.~ -: i:~ 0.421557 1.25841e7 0.109147 2.09856e6
# = [EMAIL PROTECTED] 0.12831 5.24390e6 0.0542237 5.24416e6
-:~. 0.133318 5.24358e6 0.0622004 5.24384e6
The monads i.~ i:~ ~: ~. use the same underlying algorithm,
so the efficiency boils down to details of the representation and how
you work with the representation.
----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Tuesday, December 11, 2007 9:15
Subject: Re: [Jprogramming] test for unique
To: Programming forum <[email protected]>
The problem can be solved in many ways. If efficiency is a
concernyou'd have to do some benchmarks to see which one is more
efficient.
*./@~:
i.~ -: i:~
# = [EMAIL PROTECTED]
-:~.
My guess is that the first one is the most efficient.
----- Original Message -----
From: bill lam <[EMAIL PROTECTED]>
Date: Tuesday, December 11, 2007 7:36
Subject: [Jprogramming] test for unique
To: Programming forum <[email protected]>
Any suggestion for a good phrase for testing whether all items
are unique?
eg.
unique 2 3 1
1
unique 4 2$'ABC'
0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm