Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Tom, this isn't critism (yet:). Your's is a long article that will take several passes to fully appreciate. But.. :)

I recognised this problem. Now comparing your code with my own solution which both arrive at the same results:

my @site1 = qw( AATKKM aatkkm ); my @site2 = qw( GGGGGG gggggg ); my %counts; seq_foreach_from_spec( [ \(@site1, @site2) ], sub { seq_foreach( seq_zip( ( map seq(split//), @_ ) ), sub { $counts{"@_"}++ } ) } ); print Dumper(\%counts), "\n";


my @site1 = qw( AATKKM aatkkm ); my @site2 = qw( GGGGGG gggggg ); my %counts; for my $site1 ( @site1 ){ for my $site2 ( @site2 ) { $counts{ substr( $site1, $_, 1 ) . substr( $site2, $_, 1 ) + }++ for 0 .. min( length( $site1 )-1, length( $site2 )-1 ) +; } } print Dumper \%counts;

The thing that struck me was that my perl version would be reasonably clear to most people with more than a passing familiarity with perl. Whereas your version...?

Apart from the need to go off looking up the purpose, and parameters of seq_foreach_from_spec(), seq_foreach() and seq_zip(). (Oh! and seq(). Nearly missed that tucked away in there). That "one line" construction? Phew!

I'm not adverse to terse or complicated code, but anonymous subs and user subs nested inside user subs; nested inside anonymous subs, inside a user sub along with an anon. array of array references.

When I encountered that line, the only way I could begin to makes sense of it was to deconstruct the one line into 3 for 4 using temporaries and it still left me cold? Maybe if I work through the stuff again it'll make it easier.

But given that it almost exactly the same number of lines/bytes of code; I doubt it is any quicker; certainly isn't clearer; what, besides novelty value and a cool implementation of FP, is the point?

Please don't misread that. It is a question, not a statement. I keep reading about FP, and have now installed 3 different FP langauges and downloaded 4 FP/langauge books trying to get what people are raving about.

So far, FP is interesting, and in some ways quite elegant, but it is also way over sold in some aspects. And I have to say, beyond encouraging me to continue to make full use of map, grep and List::Util where they fit, which I've taken some critisism for in the past, I don't quite get the idea of going further with FP in Perl?

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: A mini-language for sequences (part 1) by BrowserUk
in thread A mini-language for sequences (part 1) by tmoertel

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2019-10-13 20:52 GMT
    Find Nodes?
      Voting Booth?