My best so far is an 85:% perl kwic.pl a an the an ostrich a big bird the an bird ^D a BIG bird a big BIRD the an BIRD an OSTRICH %
Then I thought "as an excercise, why not do this in Ruby?" Which yielded this 142:$i{$x}=1while$x=pop;s/\w+/$i{$&}or$k{$&}.="$`\U$&\E$'"/egwhile<>;print +@k{sort keys%k}
/sp={} i={} ARGV.each{|x|i[x]=1}.clear while l=gets;l.gsub(/\S+/){|s|p[s]=''if !p[s];p[s]<<$`+$&.upcase+$'if +!i[s]}end p.sort.each{|x,y|print y}
Update:MeowChow has pointed out Key Word In Context system (golf, anyone)?, which is suspiciously similar, though not identical.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(MeowChow) Re: (golf + ruby-golf) keyword in context
by MeowChow (Vicar) on May 13, 2002 at 20:21 UTC |