in reply to Golf Challenge: all elements of an array equal


A variation on the theme of map and grep in an avoid context:
sub all_eq3 { @_=sort@_; $_[0]eq pop } # 21 chars


John.
--

Replies are listed 'Best First'.
Re: Re: Golf Challenge: all elements of an array equal
by CheeseLord (Deacon) on Jul 14, 2001 at 12:35 UTC

    My first instinct was to go the sort route, actually. You could shrink your solution by one:

    sub all_eq { #123456789_123456789_ (@_=sort@_)[0]eq pop }

    His Royal Cheeziness