Next | Advanced Programming Techniques | Slide #48 |
If the iterator returns the list items in some canonical order, you can do this:
my $both = both($it1, $it2); $item = $both->(); # get next item from $it1 or $it2
# Get rest of items in appropriate order while (defined($item = $both->())) { #... }
The both function works for any iterators
If an iterator represents a database query, this is the OR operation
Straightforward implementation on next slide
AND is a little harder, but not much
Next | Copyright © 2000 M-J. Dominus |