(How much trouble would it be to have the CPAN installation put Algorithm::Loop.3 into the standard man/man3 directory? and you should probably run a spell-checker on it...)

Personally, I was grateful for this initial paragraph under "FUNCTIONS":

Algorithm::Loops provides the functions listed below. By default, no functions are exported into your namespace (package / symbol table) in order to encourage you to list any functions that you use in the "use Algorithm::Loops" statement so that whoever ends up maintaining your code can figure out which module you got these functions from. (emphasis added)

Your sample code for sorting "both alphabetically and numerically at the same time" threw me off for a few reasons... First, it wasn't clear that it would work:

my @sorted= Filter { s#\d{2}(\d+)#\1#g } sort Filter { s#(\d+)# sprintf "%02d%s", length($1), $1 #g } @data;
Looks to me like you should include "e" with "g" at the end of that second s### (same might apply to the "HTML templating" example). Also, why use "\1" (rather than $1) in the right-hand side of the first s###? And maybe provide at least one extra line of code at the beginning, like:
my @data = qw/a.1 a.5 a.11 b.3 b.15/;
or something equivalent, along with the intended output, to clarify what kind of sorting you mean (and to make sure the snippet really produces the intended result).

For the "MapCar*" discussion, I'd skip the arcane remarks about using map in a scalar context (it doesn't aid in using your module). The "Formatting a date-time" example seems overly "golfed" (that is, obfuscated). Maybe my mileage is just way different, but it didn't yield what I think was expected:

use Algorithm::Loops (MapCarE); my $dateTime= join "", MapCarE { sprintf "%02d%s", pop()+pop(), pop() } [ (localtime)[5,4,3,2,1,0] ], [ 1900, 1, (0)x4 ], [ "// ::" =~ /./g, "" ]; print $dateTime,$/; print scalar localtime(),$/; ## for a more familiar view __OUTPUT__ 1900103018003000100130037 Tue Sep 30 01:13:37 2003
It took me a while to figure out that it works better with "shift()" instead of "pop()" -- if you actually want to keep this example. (Later examples using "pop()" might have the same property.)

The NestedLoops stuff is a bit hard to grok, but in this case the examples do help (especially since they seem to work "out of the box"). The conceptual problem here, I think, is the cognitive disconnection between a real nested loop structure vs. a linear set of parameters (often combined with the "x" operator) that describe such a structure.

The challenge will be to compose a description of the NestedLoop syntax that "resonates" somehow (relates more or less directly) with the traditional concept of nesting. Maybe something like a "3-D" example would help, too; e.g. given axes that extend 8 units on X, 6 units on Y, and 3 units on Z, populate the 3-D matrix in some interesting (but not too complicated) way, like initializing all points in the successive Z planes to -1, 0 and 1. (But then again, maybe that wouldn't help...)

Edit by tye, change PRE to BLOCKQUOTE


In reply to Re: Algorithm::Loops released by graff
in thread Algorithm::Loops released by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.