Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: Compare two arrays of simple numbers

by Prof Vince (Friar)
on Oct 03, 2007 at 08:36 UTC ( #642341=note: print w/replies, xml ) Need Help??

in reply to Re^2: Compare two arrays of simple numbers
in thread Compare two arrays of simple numbers

Well that's (worst case) O(n) right there. :-)
That's what linear means.
Does != even have a meaning in list context ?
Edit: It doesn't force scalar context, but seems to compare array lengths. See :
sub zero { return (0, 0) } print +(zero() == 2) ? "scalar\n" : "list\n"; my @a = (0, 1); my @b = (1, 0); my @c = (0, 2 , 1); print +(@a == @b) ? "same length\n" : "not\n"; print +(@a == @c) ? "same length\n" : "not\n";
Anyway, I think perl doesn't actually build the lists and directly optimize that to the array size, which should make it constant time.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://642341]
[shmem]: moment... lemme see...
[shmem]: Python 2.7.9
[shmem]: but! perl4 doesn't suck.
[LanX]: better try 3
[shmem]: that python stuff is none of my business.
[shmem]: but sometimes I have to debug things implemeted by "the other team" and stick their nose into their dirt.
[shmem]: because it affects "my team"

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-03-20 18:33 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (257 votes). Check out past polls.