Yes and no. The basic definition of
[op] in Perl 6 is syntactic rather than semantic, so it will do either foldl or foldr depending on the syntactic associativity of the operator in question. But the syntactic definition goes a little beyond that, insofar as it can be applied to context-dependent syntactic operators that have no fixed run-time meaning, such as
[;] or
[,]. Since the meanings of
; and
, depend on syntactic context, so do the meanings of
[;] and
[,].
Furthermore, it can be applied to operators that are neither left nor right-associative, such as the various list-associative operators, which in Perl 6 includes the comparison operators. So you can
write
[<] @array
to mean
@array[0] < @array[1] < @array[2] ...
which will tell you if the array is monotonically increasing without having to do strange semantic contortions to separate value from success (see Icon).
There will still be need for underlying foldl and foldr equivalents to force folding "against the grain", but for most purposes (including educational and visual), the [op] form is more accessible, I think.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.