NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
boolean test (Score:2)
If you want to go beyond a simple boolean, the index of the first out of order element sounds a lot more useful than the proprtion of sorted neighbours - and, like the boolean result, it can short circuit the scan of the list as soon as an out of order pair is found.
Reply to This
Re:boolean test (Score:1)
An
is_sorted @listpredicate would be an interesting builtin/XS/Inline function, and should run faster than sort (if coded equally well). It should run about the same speed as aleast @listsort-variant optimized toreturn (sort @_)[0].However, I'm not sure
is_sortedshould be calledscalar sort, that doesn't seem any better than callingleastasscalar sort. Changingsortfrom verb-transitive to verb-predicate when going from list to scalar context is ratherBill
# I had a sig when sigs were cool
use Sig;