Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: Fast Way to Return Unique Array of Array

by pg (Canon)
on Sep 05, 2005 at 04:23 UTC ( [id://489138]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Fast Way to Return Unique Array of Array
in thread Fast Way to Return Unique Array of Array

No, your program does not return the correct answer all the time. The problem is that your code would not work with data that contains ','.

Testing is not to prove one's code is correct, but rather to find out the exceptions.

There is no problem with my input. By readng your code, I knew that it would fail if the data contains ',', as your program first concat elements with ',', and then split by ','. When the data contains ',', the problem arises, as:

  • Your code cannot split the concated string back to the orginal elements correctly any more.
  • Also, that two concated strings are the same, does not mean that the two original arrays before concat are the same. In my example, the two different arrays will both concat to "a,,b,c", and that fails your code.

You cannot say that the input is wrong, because your code cannot handle it. In this thread, the correct solutions should be able to handle any two dimentional AoA. Your program does not satisfy this.

Your code is not bad, but it certainly can be better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://489138]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found