Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I came up with a similar, and arguably neater implementation:
but rejected it because 'sum' is a (glob) variable. In theory, it is possible to avoid the naming of the sub, thereby achieving "anonymous recursion", by using the Y-combinator. And the Y-combinator has been achieved in Perl by a former regular here. Putting it together you get:
But whilst that achieves the Y-combinators goal of recursion without adding the sub to the permanent namespace, it still requires the naming of the pesky closure $rec. And of course, requires you to add the Y-combinator to the permanent namespace first:
And that's already more obfuscation as I want to wrap my brain around, even in an obfuscation section post! My final thought is that the simplest mechanism that fits the OPs breif is just:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re^2: (almost) foldl
by BrowserUk
|
|