in reply to Re: Looking for function similer to member() in SKILL
in thread Looking for function similer to member() in SKILL
#!/usr/bin/perl use strict; use warnings; my @set = qw(one bright day in the middle of the night); my %pos; # Preprocess @set { no warnings 'uninitialized'; vec( $pos{ ord( $set[ $_ ] ) }, $_, 1 ) = 1 for 0 .. $#set; } while ( my $val = <DATA> ) { chomp $val; my $bitstr = $pos{ ord( $val ) } or next; my $i = length( $bitstr ) * 8 - 1; while ( $i-- ) { print "$val\n" and last if vec($bitstr, $i, 1) && $val eq $set +[ $i ]; } } __DATA__ one two buckle my shoe the cat in the hat
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Looking for function similer to member() in SKILL
by Anonymous Monk on Jun 27, 2005 at 07:52 UTC | |
by Limbic~Region (Chancellor) on Jun 27, 2005 at 12:41 UTC | |
by Anonymous Monk on Jun 27, 2005 at 14:27 UTC | |
by Limbic~Region (Chancellor) on Jun 27, 2005 at 14:31 UTC |