[vox-tech] Matching Contents of Lists

Micah J. Cowan micah at cowan.name
Fri Jul 8 14:15:57 PDT 2005


On Fri, Jul 08, 2005 at 03:53:00PM -0500, Jay Strauss wrote:
> 
> 
> Micah J. Cowan wrote:
> > On Fri, Jul 08, 2005 at 10:28:00AM -0500, Jay Strauss wrote:
> > 
> >>Micah J. Cowan wrote:
> > 
> > 
> > <snip>
> > 
> >>>First, you will need to create a comparison function, that will return
> >>>an integer less than, greater than, or equal to zero depending on
> >>>whether its first argument compares lexically less than, greater than,
> >>>or equal to its second argument. This function should match based on
> >>>your rules given above, and is meant as an analog for the cmp and <=>
> >>>operators.
> > 
> > 
> > <snip>
> > 
> >>Won't this just match identical records, and not account for his 
> >>matching rules?  Seems like this is just a programmatic SQL join
> > 
> > 
> > (Read the above paragraph).
> > 
> 
> I didn't really know what you meant by "lexically".  I thought you might 
> be saying:
> 
> return -1 if $a lt $b;
> return 0 if $a eq $b;
> return 1 if $a gt $b;

Well, and that's more or less what "lexically" would mean, if I hadn't
qualified it with "[matching] based on your rules above."

But there wouldn't be much point to rolling your own function otherwise,
when cmp works just fine ;-)

> But I now understand, you want to build sophisticated comparison, maybe 
> even character by character, to determine -1,0,1.  Seems hard, but 
> you've probably already boiled it down to a one-liner :)

No need for character by character comparison: in fact your regex-based
parsing would be fine. Just build the parsed string for each one, and
then do a cmp on that.

-- 
Micah J. Cowan
micah at cowan.name


More information about the vox-tech mailing list