Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by tilly (Archbishop)
on Sep 09, 2008 at 05:30 UTC ( #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
Node Status?
node history
Node Type: note [id://709973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-08-20 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls