Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 38.854.217 Times

Closure::Loop 0.0.2

  Date Added: June 11, 2010  |  Visits: 807

Closure::Loop

Report Broken Link
Printer Friendly Version


Product Homepage
Download (88 downloads)



Closure::Loop is a Perl module with redo, last, next for closure based loops. SYNOPSIS package MyIterator; use Closure::Loop; # mixin sub new { my $class = shift; return bless { }, $class; } sub forAll { my $self = shift; my $cb = pop || die "No callback"; for my $i (@_) { eval { $self->yield($cb, $i); }; last if $self->is_last; die $@ if $@; } } package main; my $iter = MyIterator->new(); my @in = ( 1, 2, 3 ); my @out = ( ); $iter->forAll(@in, sub { my $i = shift; $iter->next if $i == 2; # skip value push @out, $i; }); # @out is ( 1, 3 ) An idea that Perl programmers can usefully borrow from Ruby is the concept of synthesizing new looping constructs by passing a block of code to a function that repeatedly calls it with successive values in a sequence. In Ruby this looks like this: def count_to_ten i = 1 while i <= 10 yield i i = i + 1 end end count_to_ten do |i| puts i end In Perl the same thing looks like this: sub count_to_ten { my $block = shift; my $i = 1; while ($i <= 10) { $block->($i); $i++; } } count_to_ten(sub { my $i = shift; print "$in"; }); That example is deliberately trivial. In practice this technique can be used to implement a loop like construct that, for example, walks the nodes in a binary tree - something that isnt easy with a normal loop. The body of the loop is actually a closure so it has complete access to the lexical scope in which it is defined. In short it works just like the body of a loop for our purposes - with one exception. For normal Perl loops its possible to use the last, next and redo statements to modify iteration of the loop. That wont work as expected here. If we use them in our pseudo loop well get a warning (because were actually trying to jump out of a subroutine using them) and theyll end up affecting the first enclosing loop or block they find - which may impact unpredictably on the iterator function, particularly if it doesnt actually contain a loop. This module makes it easy to implement modules that expose iterator methods and which provide an interface for controlling the iteration of the loop which resembles an object oriented version of Perls normal loop control statements..

Requirements: No special requirements
Platforms: Linux
Keyword: Closure Closureloop Last Libraries Module Perl Perl Module Programming Redo
Users rating: 0/10

License: Freeware Size: 6.14 KB
USER REVIEWS
More Reviews or Write Review


CLOSURE::LOOP RELATED
Communication  -  phpbb 3 last topics module 1.0.2
Simple module which will show your last topics of your phpbb3 forum in your Joomla Site. Just fill some require parameters and start use it. Do NOT require registration to download!
10 KB  
Communication  -  DphpBB3 Last Topics 1.4.1
DphpBB3 Last Topics module (mod_dphpbb3_last_topics) shows the last topics from your phpBB 3.0.x forum. It's the excellent module for Joomla! 1.5 site with phpBB3 forum to display forum activity on the site.There is no need to integrate forum and...
20.48 KB  
Utilities  -  Dylan Code Collection 1.7
A collection of useful libraries written in the Dylan programming language. The intent of this project is to provide easily accessible libraries for people developing applications using Functional Developer and/or Gwydion Dylan.
673.63 KB  
Programming  -  kin 0.0.2
kin is a set of libraries and tools supporting meta-programming for engineering and technical computing applications. This JVM version of kin has been superseded by the stand-alone version being developed at http://purl.org/net/kin.
477.44 KB  
Libraries  -  Alien Perl module 0.91
Alien Perl module package contains external libraries wrapped up for your viewing pleasure! SYNOPSIS perldoc Alien; Alien is a package that exists just to hold together an idea, the idea of Alien:: packages, so there is no code here, just...
10.24 KB  
Libraries  -  FFI::Library 1.02
FFI::Library is a module with Perl Access to Dynamically Loaded Libraries. SYNOPSIS use FFI::Library; $lib = FFI::Library->new("mylib"); $fn = $lib->function("fn", "signature"); $ret = $fn->(...); This module provides access from Perl to...
16.38 KB  
Libraries  -  Alien::scriptaculous 1.002
Alien::scriptaculous is a Perl module for installing and finding script.aculo.us. SYNOPSIS use Alien::scriptaculous; ... $version = Alien::scriptaculous->version(); $path = Alien::scriptaculous->path(); ... Alien::scriptaculous->install(...
100.35 KB  
Libraries  -  Inline-API 0.44
Inline-API is a Perl module that teach you how to bind a programming language to Perl using Inline.pm. SYNOPSIS #!/usr/bin/perl use Inline Foo; say_it(foo); # Use Foo to print "Hello, Foo" __Foo__ foo-sub say_it { foo-my $foo =...
91.14 KB  
Libraries  -  perlfaq3 5.8.8
perlfaq3 Perl module contains programming tools. How do I do (anything)? Have you looked at CPAN (see perlfaq2)? The chances are that someone has already written a module that can solve your problem. Have you read the appropriate manpages?...
12.2 MB  
Libraries  -  Test::STDmaker 0.23
Test::STDmaker is a Perl module to generate test scripts, demo scripts from a test description short hand. SYNOPSIS ####### # Procedural (subroutine) interface # use Test::STDmake qw(find_t_roots get_data perl_command); @t_path =...
133.12 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB