The distinction is that in a pure FP language, Autrijus' emminently clever code would not be possible.

The inclusion of the monad into the previously pure FP Haskell, is testiment to the practical restrictions that pure FP implies. There are some tasks that FP algorithms are far and away the best alternative. There are some tasks that imperative algorithms (with their inherent utilisation of side effects) are more practical.

Once you remove the "no side-effects" aspect from FP, you end up with the main distinction between FP and imperative code being the syntax used. For some algorithms, a declarative syntax is the most clear and concise. For some algoriths, a recursive definition is the easiest to code, understand and maintain--whether using declarative or imperative syntax. For some algorithms, good ol'imperative loops and blocks and side-effects is just the ticket.

My preference--and there is no implication in this that seeks to restrict anyone else to my choices--is for a language that supports all these styles of syntax, without artificial restristions. For me, currently, the best choice available is Perl, which is why I come back to Perl in preference to all the other languages I've tried over the last few years.

My conclusion from Autrujus' example, is that to address the constraints imposed by my posted problem (memory), the requirement is to utilise side-effects. What Autrujus demonstrated was that this can indeed be done within Haskell.

So, we reach the point where the given task can be tackled in both languages, so the choice of language comes down to personal preference--mine is Perl.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

In reply to Re^3: GHC shuffle more efficient than Perl5. by BrowserUk
in thread Why is the execution order of subexpressions undefined? by BrowserUk

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.