Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: [OT] Perl / Computer Science Science Fair Projects

by tilly (Archbishop)
on Sep 09, 2008 at 05:30 UTC ( [id://709973]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    var x = "hello "
    var my_closure = function (y) {
      alert(x + y);
    }
    my_closure("world");
    
  2. or download this
    for (@some_array) {
      # Declaring this in the loop creates a new variable per
    ...
      };
    }
    # We now have one closure per array element.
    
  3. or download this
    for (var i = 0; i < some_array.length; i++) {
      // Declaring this in the loop creates a one variable for
    ...
      });
    }
    // All closures now point at the last element.
    
  4. or download this
    for (var i = 0; i < some_array.length; i++) {
      // This declares and immediately calls a function, and x
    ...
      )(some_array[i]); // And here is where we bind the value.
    }
    // We now have one closure per array element.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://709973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-24 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found