Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl
use List::Util 'first';
print "ok\n" if first {$_ eq $x} @list;

grep() will find all the elements that match... in a large list this may waste time. first() will return true as soon as the element is found.
print "Found 'foo'\n" if grep {$_ eq $x} @list;

The inside of the curly braces for a hash(map) reference is automatically stringified.
with Ada.Containers.Vectors;
Result := List.Contains (X);

New implementation...