Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Update: It has been pointed out to me that this post can be read as having hostile intent towards JadeNB. No such intent exists!

If there is an latent hostility underlying this post, it is directed at CS programs that concentrate on teaching gradtuate CS-only problems, instead of either real-world problems, or backing up their CS problem explorations with practical implementaions and examples of real-world use. Hence no one want to employ new grads until they've had 2 to 3 years writing "real" code.

But that does in no way preclude individuals from exploring whatever takes their fancy. I spend much of my time exporing ultimately useless tangents.

If there is any intended implied critisism of JadeNB, it is that he did not (has not) make clear what his actual goal in a maner that could be verified. Hence may of the solutions offered garnered repsponses like: "but that uses copies rather than aliases"; without providing any explanation or reason why aliases would be preferable for his (unstated) final objective. But I see others have voiced that critisism rather more bluntly.


I have a number of dastardly intentions, but perhaps the simplest is that I'd like to be able to write
sub lambda { my $f = $_[1]; for my $x ( $_[0] ) { return sub { local $x = $_[0]; return $f->(); } } }

Reading between the lines of your post (with its myriad updates), and your responses to peoples suggestions; it seems likely that what you are trying to achieve--without having stated it is your objective--is a Perlish Y Combinator?

If so, let me tell you it's already been done, and it looks like this:

sub Y { my ( $curried_rec ) = @_; sub { my ( $f1 ) = @_; $curried_rec->( sub { $f1->( $f1 )->( @_ ) } ) }->( sub { my ( $f2 ) = @_; $curried_rec->( sub { $f2->( $f2 )->( @_ ) } ) } ) }

Which is apprently very cool in CS circles because it allows you to do stuff like this:

print Y( sub { my ( $rec ) = @_; sub { my ( $n ) = @_; $n < 2 ? 1 : $n * $rec->( $n - 1 ); } } )->( 10 );; 3628800

Though quite why that is so cool--beyond being unintuative enough that CS students are unlikely to be able to work it out for themselves; and even once the Masterful lecturer has written it up on the board (copied rote from his notes), and "explained" it, it remains opaque enough to leave the student thinking the lecturer must be very clever--is beyond my reasoning.

NOTE: The above implementation is by the much missed Aristotle; and you can find his explaination of its derivation here.


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: Local for lexicals by BrowserUk
in thread Local for lexicals by JadeNB

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found