Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Why not support this syntax?

by tadman (Prior)
on Apr 24, 2001 at 15:05 UTC ( [id://75083]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Why not support this syntax?
in thread Why not support this syntax?

I could only guess that it would be:     $mystery = ($a < $b) && ($b < $c) && ($c < $d) && ($d < $f); As in, for any:     A x B y C Where 'x' and 'y' are one of ('>','>=','<','<='), then the equivalent would be:     (A x B) && (B y C) Which would also hold true for:
A < B >= C -> (A < B) && (B >= C) A > B < C -> (A > B) && (B < C)
And so forth.

Replies are listed 'Best First'.
Re: Re^3: Why not support this syntax?
by clemburg (Curate) on Apr 24, 2001 at 15:29 UTC

    Good idea, and we can even cover that one ourselves, too:

    sub is_ordered_according_to { my ($binary_predicate, @values) = @_; if (@values < 3) { return $binary_predicate->(@values); } else { return $binary_predicate->($values[0], $values[1]) && is_ordered_according_to($binary_predicate, @values[1..$#values]); } } sub less_than { return shift() < shift(); } print is_ordered_according_to(\&less_than, 1, 2, 3, 4, 5, 6) ? "yes" : "no", "\n" ; print is_ordered_according_to(\&less_than, 3, 2, 1, 4, 5, 6) ? "yes" : "no", "\n" ; print is_ordered_according_to(\&less_than, 1, 2, 3, 4, 6, 5) ? "yes" : "no", "\n" ;

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

      Nice, but try this:
      $val = $min <= $x < $y <= $z <= $max
      IMO, A syntactic solution would be both cleaner and faster.
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print

      Cool. If you don't mind, I'll just add this to my personal collection of bits o'code.

      Good idea, and we can even cover that one ourselves, too

      But we can cover *anything* ourselves ... with enough effort.

      From another of your posts on the same topic:

      Perl is a language for getting your job done - right. After writing this little subroutine, the job is done. Why wait for other people to do jobs for you that you can do for yourself in 30 seconds.

      I don't think anyone said anything about *waiting*.

      Making Perl6 will require a great deal of effort, it's going to happen regardless of whether or not this particular syntax is included, and the process of deciding what the syntax will be has been deliberately opened to public debate.

      So why not let everyone know on what we think said effort should be spent constructing?

      Philosophically yours,

      Scott

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://75083]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.