Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    # -*- CPerl -*-
    ...
    foreach (@ARGV) {
      print $_, search($Set, $_) ? ' is' : ' is not', " in the set\n";
    }
    
  2. or download this
    $ ./bsearch.pl 1,2,5,6,9,10,41-56 1 4 42 17
    $Set = [[1,2],[5,6],[9,10],[41,'56']];
    ...
    4 is not in the set
    42 is in the set
    17 is not in the set
    
  3. or download this
    $ ./bsearch.pl 1,2,11-16,6,7,19,9,5-8,13,14,15,4 1 2 3 4 5 8 9 10 11 1
    +2 16 17 18 19 20
    $Set = [[1,2],[4,9],[11,16],19];
    ...
    18 is not in the set
    19 is in the set
    20 is not in the set