Result:
Your query is still running in background...Search in progress... at this time found 556 distributions and 696 files matching your query.
Next refresh should show more results. ( run in 2.467 )


Hash-Weighted-Categorize

 view release on metacpan or  search on metacpan

lib/Hash/Weighted/Categorize/Parser.pm  view on Meta::CPAN

no warnings 'recursion';use List::Util qw(first);
use Data::Dumper;

our $FILENAME=__FILE__;

sub firstval(&@) {
  my $handler = shift;
  
  return (grep { $handler->($_) } @_)[0]
}

sub lastval(&@) {
  my $handler = shift;
  
  return (grep { $handler->($_) } @_)[-1]
}

lib/Hash/Weighted/Categorize/Parser.pm  view on Meta::CPAN

use warnings;
use Carp;
use Data::Dumper;
use List::Util qw(first);

sub firstval(&@) {
  my $handler = shift;
  
  return (grep { $handler->($_) } @_)[0]
}

sub lastval(&@) {
  my $handler = shift;
  
  return (grep { $handler->($_) } @_)[-1]
}

 view all matches for this distribution


Hiredis-Raw

 view release on metacpan or  search on metacpan

t/Redis.pm  view on Meta::CPAN

use File::Which qw(which);

use base qw(Exporter);
our @EXPORT = qw(test_redis);

sub test_redis(&;$) {
    my $cb        = shift;
    my $args      = shift;

    my $redis_server = which 'redis-server';
    unless ($redis_server && -e $redis_server && -x _) {

 view all matches for this distribution


Hook-AfterRuntime

 view release on metacpan or  search on metacpan

lib/Hook/AfterRuntime.pm  view on Meta::CPAN

sub run {
    my $id = shift;
    $IDS[$id]->();
}

sub after_runtime(&) {  ## no critic
    my ( $code ) = @_;
    my $id = get_id( $code );

    B::Hooks::Parser::inject(
        "; my \$__ENDRUN" . $HOOK_ID++ . " = Hook::AfterRuntime->new($id);"

 view all matches for this distribution


Hook-LexWrap

 view release on metacpan or  search on metacpan

t/test.t  view on Meta::CPAN

use Hook::LexWrap;
print "1..54\n";

sub ok   { print "ok $_[0]\n" }
sub fail(&) { print "not " if $_[0]->() }

sub actual { ok $_[0]; }


actual 1;

 view all matches for this distribution


Hook-Modular

 view release on metacpan or  search on metacpan

lib/Hook/Modular/Builder.pm  view on Meta::CPAN

sub enable { $_enable->(@_) }
sub global { $_global->(@_) }
sub log_level { $_log_level->(@_) }
sub cache_base { $_cache_base->(@_) }

sub builder(&) {
    my $block = shift;
    my $self  = __PACKAGE__->new;
    local $_enable = sub {
        $self->do_enable(@_);
    };

 view all matches for this distribution


Hoppy

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


IO-Async

 view release on metacpan or  search on metacpan

lib/IO/Async/LoopTests.pm  view on Meta::CPAN

   }

   done_testing;
}

sub wait_for(&)
{
   # Bounce via here so we don't upset refcount tests by having loop
   # permanently set in IO::Async::Test
   IO::Async::Test::testing_loop( $loop );

lib/IO/Async/LoopTests.pm  view on Meta::CPAN

   &IO::Async::Test::wait_for( @_ );

   IO::Async::Test::testing_loop( undef );
}

sub time_between(&$$$)
{
   my ( $code, $lower, $upper, $name ) = @_;

   my $start = time;
   $code->();

lib/IO/Async/LoopTests.pm  view on Meta::CPAN


(Previously called C<child>)

=cut

sub run_in_child(&)
{
   my $kid = fork;
   defined $kid or die "Cannot fork() - $!";
   return $kid if $kid;

 view all matches for this distribution


IO-Lambda

 view release on metacpan or  search on metacpan

lib/IO/Lambda.pm  view on Meta::CPAN

# Part II - Procedural interface to the lambda-style programming
#
#################################################################

sub _lambda_restart { die "lambda() is not restartable" }
sub lambda(&)
{
	my $cb  = _subname(lambda => $_[0]);
	my $l   = __PACKAGE__-> new( sub {
		# initial lambda code is usually executed by tail/tails inside another lambda,
		# so protect the upper-level context

lib/IO/Lambda.pm  view on Meta::CPAN

	$THIS->{frames}->{$name} = [ $METHOD, $CALLBACK, @CONTEXT ];
	return $name;
}

# exceptions and backtracing
sub catch(&$)
{
	my ( $cb, $event) = @_;
	my $who = (caller(1))[3];
	my @ctx = @CONTEXT;
	confess "catch callback already defined" if $event-> [WATCH_CANCEL];

lib/IO/Lambda.pm  view on Meta::CPAN

		($AGAIN ? delete($self-> {cancel}) : undef),
	)
}

# rwx($flags,$handle,$deadline)
sub rwx(&)
{
	return $THIS-> override_handler('rwx', \&rwx, shift)
		if $THIS-> {override}->{rwx};

	$THIS-> add_watch( 

lib/IO/Lambda.pm  view on Meta::CPAN

		@CONTEXT[0,1,2,0,1,2]
	)
}

# readable($handle,$deadline)
sub readable(&)
{
	return $THIS-> override_handler('readable', \&readable, shift)
		if $THIS-> {override}->{readable};

	$THIS-> add_watch( 

lib/IO/Lambda.pm  view on Meta::CPAN

		@CONTEXT[0,1,0,1]
	)
}

# writable($handle,$deadline)
sub writable(&)
{
	return $THIS-> override_handler('writable', \&writable, shift)
		if $THIS-> {override}->{writable};
	
	$THIS-> add_watch( 

lib/IO/Lambda.pm  view on Meta::CPAN

		($AGAIN ? delete($self-> {cancel}) : undef),
	)
}

# timeout($deadline)
sub timeout(&)
{
	return $THIS-> override_handler('timeout', \&timeout, shift)
		if $THIS-> {override}->{timeout};
	$THIS-> add_timer( _subname(timeout => shift), \&timeout, @CONTEXT[0,0])
}

lib/IO/Lambda.pm  view on Meta::CPAN

		$cb-> ();
	}) if $cb;
}

# tail( $lambda, @param) -- initialize $lambda with @param, and wait for it
sub tail(&)
{
	return $THIS-> override_handler('tail', \&tail, shift)
		if $THIS-> {override}->{tail};
	
	my ( $lambda, @param) = context;

lib/IO/Lambda.pm  view on Meta::CPAN

	$THIS-> add_tail( _subname(tail => shift), \&tail, $lambda, $lambda, @param);
}


# tails(@lambdas) -- wait for all lambdas to finish
sub tails(&)
{
	return $THIS-> override_handler('tails', \&tails, shift)
		if $THIS-> {override}->{tails};
	
	my $cb = _subname tails => $_[0];

lib/IO/Lambda.pm  view on Meta::CPAN

	my $this = $THIS;
	$this-> watch_lambda( $_, $watcher) for @lambdas;
}

# tailo(@lambdas) -- wait for all lambdas to finish, return ordered results
sub tailo(&)
{
	return $THIS-> override_handler('tailo', \&tailo, shift)
		if $THIS-> {override}->{tailo};
	
	my $cb = _subname tailo => $_[0];

lib/IO/Lambda.pm  view on Meta::CPAN

		);
	};
}

# any_tail($deadline,@lambdas) -- wait for any lambda to finish within time
sub any_tail(&)
{
	return $THIS-> override_handler('any_tail', \&any_tail, shift)
		if $THIS-> {override}->{any_tail};
	
	my $cb = _subname any_tail => $_[0];

lib/IO/Lambda.pm  view on Meta::CPAN

		again;
	}}
}

# curry(@a -> $l) :: @a -> @b
sub curry(&)
{
	my $cb = $_[0];
	lambda {
		context $cb->(@_);
		&tail();

 view all matches for this distribution


IO-NestedCapture

 view release on metacpan or  search on metacpan

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDIN> for the duration of the given block.

=cut

sub capture_in(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture input and then turn off capture, even on error
	$self->start(CAPTURE_STDIN);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDOUT> for the duration of the given block.

=cut

sub capture_out(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture output and then turn off capture, even on error
	$self->start(CAPTURE_STDOUT);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDERR> for the duration of the given block.

=cut

sub capture_err(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture error output and then turn off capture, even on error
	$self->start(CAPTURE_STDERR);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDIN> and C<STDOUT> for the duration of the given block.

=cut

sub capture_in_out(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture input and output and then turn off capture, even on error
	$self->start(CAPTURE_IN_OUT);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDIN> and C<STDERR> for the duration of the given block.

=cut

sub capture_in_err(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture input and error output and then turn off capture, even on error
	$self->start(CAPTURE_IN_ERR);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDOUT> and C<STDERR> for the duration of the given block.

=cut

sub capture_out_err(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture output and error output and then turn off capture, even on error
	$self->start(CAPTURE_OUT_ERR);

lib/IO/NestedCapture.pm  view on Meta::CPAN


This subroutine captures C<STDIN>, C<STDOUT>, and C<STDERR> for the duration of the given block.

=cut

sub capture_all(&) {
	my $self = IO::NestedCapture->instance;
	my $code = shift;

	# capture input, output and error output and then turn off capture, even on
	# error

 view all matches for this distribution


IPC-MPS

 view release on metacpan or  search on metacpan

IPC/MPS.pm  view on Meta::CPAN

END {
	$ipc_loop or @spawn and carp "Probably have forgotten to call receive.";
	close $_ foreach values %fh2fh;
}

sub spawn(&) {
	my ($spawn) = @_;
	socketpair(my $child, my $parent, AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, PF_UNSPEC) or die "socketpair: $!";
	my $vpid = refaddr $child;
	push @spawn, [$vpid, $child, $parent, $spawn];
	return $vpid;

IPC/MPS.pm  view on Meta::CPAN

	}
	return 1;
}


sub receive(&) {
	my ($receive) = @_;

	$DEBUG > 1 and print "Call receive in $self_vpid (\$\$=$$)\n";

	local $SIG{CHLD} = "IGNORE";

 view all matches for this distribution


Importer

 view release on metacpan or  search on metacpan

t/units.t  view on Meta::CPAN


use Importer 'Test::More';

my $CLASS = 'Importer';

sub dies(&) {
    my $code = shift;

    my $err;
    {
        local $@;

t/units.t  view on Meta::CPAN


    $@ = $err;
    return $err || 1;
}

sub warns(&) {
    my $code = shift;

    my $warn;
    my $warned = 0;
    local $SIG{__WARN__} = sub { ($warn) = @_; $warned++ };

 view all matches for this distribution


Iterator-Simple

 view release on metacpan or  search on metacpan

lib/Iterator/Simple.pm  view on Meta::CPAN

)];

push @EXPORT_OK, @{$EXPORT_TAGS{basic}}, @{$EXPORT_TAGS{utils}};
$EXPORT_TAGS{all} = [@EXPORT_OK];

sub iterator(&) { ITERATOR_CLASS->new($_[0]);}

# name: iter
# synopsis: iter($object);
# description:
#   autodetect object type and turn it into iterator

lib/Iterator/Simple.pm  view on Meta::CPAN

# description:
#   simplified version of ifilter, no skip, no inflate.
# param: code: transformation code;
# param: source: source iterable object
# return: transformed iterator;
sub imap(&$) {
	my($code, $src) = @_;
	$src = iter($src);
	ref($src)->new(sub {
		local $_ = $src->();
		return if not defined $_;

lib/Iterator/Simple.pm  view on Meta::CPAN

# description:
#   iterator filter iterator
# param: code: filter condition
# param: source: source iterable object
# return: filtered iterator
sub igrep(&$) {
	my($code, $src) = @_;
	$src = iter($src);
	ref($src)->new(sub {
		while(defined(my $rv = $src->())) {
			local $_ = $rv;

 view all matches for this distribution


JBD

 view release on metacpan or  search on metacpan

lib/JBD/Parser.pm  view on Meta::CPAN

use JBD::Core::Exporter ':omni';
use Carp 'croak';

# @param codref A code block.
# @return JBD::Parser typed coderef.
sub parser(&) { bless $_[0], __PACKAGE__ }

# @param string $type A token type.
# @param mixed $val A token value, possibly undef.
# @return coderef A stack trace printer sub.
sub stack_tracer($$) {

 view all matches for this distribution


JS

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected, $name;
        diag Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


JSON-String

 view release on metacpan or  search on metacpan

t/efficient.t  view on Meta::CPAN

use JSON::String;

my $codec = JSON::EncodeCounter->new->canonical;
JSON::String->codec($codec);

sub count_encodings(&$$) {
    my($block, $expected_count, $msg) = @_;

    $codec->reset_encode_counter();
    $block->();
    is($codec->encode_counter, $expected_count, $msg);

 view all matches for this distribution


JSONRPC-Transport-TCP

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


Jemplate

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


Jifty

 view release on metacpan or  search on metacpan

lib/Jifty/View/Declare/Helpers.pm  view on Meta::CPAN

      }
  }

=cut

sub js_handlers(&;@) {
    my $code = shift;
    my $element = Jifty::Web::Form::Element->new({$code->()});
    my %js = $element->javascript_attrs;
    Template::Declare::Tags::append_attr($_ => $js{$_}) for keys %js;
    return @_;

 view all matches for this distribution


JiftyX-Markapl

 view release on metacpan or  search on metacpan

examples/Oreo/lib/Oreo/View.pm  view on Meta::CPAN

use warnings;

use Markapl;
use JiftyX::Markapl::Helpers;

sub page(&) {
    my $content_cb = shift;
    return sub {
        outs_raw ("<!doctype html>\n");
        html {
            head {

 view all matches for this distribution


K

 view release on metacpan or  search on metacpan

t/QServer.pm  view on Meta::CPAN

use FindBin qw/$Bin/;

use base qw(Exporter);
our @EXPORT = qw(test_qserver);

sub test_qserver(&;$) {
    my $cb        = shift;
    my $args      = shift;

    my $q = which 'q';
    unless ($q && -e $q && -x _) {

 view all matches for this distribution


Kamaitachi

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


Kelp-Module-WebSocket-AnyEvent

 view release on metacpan or  search on metacpan

lib/Kelp/Module/WebSocket/AnyEvent.pm  view on Meta::CPAN

};
attr "on_error";

# This function is here to work around Twiggy bug that is silencing errors
# Warn them instead, so they can be logged and spotted
sub _trap(&)
{
	my ($block) = @_;
	try {
		$block->();
	}

 view all matches for this distribution


Kook

 view release on metacpan or  search on metacpan

lib/Kook/Util.pm  view on Meta::CPAN

    for (@_) {
        ref($_) eq 'ARRAY' ? _flatten($buf, @$_) : push(@$buf, $_);
    }
}

sub first(&@) {
    my ($block, @arr) = @_;
    for (@arr) {
        return $_ if $block->($_);
    }
    return;

 view all matches for this distribution


LWP-UserAgent-Keychain

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


Language-Farnsworth

 view release on metacpan or  search on metacpan

lib/Language/Farnsworth/Error.pm  view on Meta::CPAN

{
	$_[0]->{msg};
}

#wraps code and catches die() and wraps the error in our class
sub perlwrap(&;$)
{
#	print "INPERLWRAP\n";
	my $code=shift;
	my $default=shift;
	$default=EPERL unless defined $default;

 view all matches for this distribution


Language-FormulaEngine

 view release on metacpan or  search on metacpan

t/10-scanner.t  view on Meta::CPAN

#! /usr/bin/env perl
use Test2::V0 -target => 'Language::FormulaEngine::Parser';
use Try::Tiny;

# capture error message of code that should die
sub error_of(&) { my $sub= shift; try { $sub->(); 'No Exception Thrown' } catch { $_ } }

my %_str_escapes= ("\0" => '\0', "\n" => '\n', "\r" => '\r', "\t" => '\t', "\f" => '\f', "\b" => '\b', "\a" => '\a', "\e" => '\e', "\\" => '\\' );
sub str_escape_char { exists $_str_escapes{$_[0]}? $_str_escapes{$_[0]} : sprintf((ord $_[0] <= 0xFF)? "\\x%02X" : "\\x{%X}", ord $_[0]); }
sub str_escape { my $str= shift; $str =~ s/([^\x20-\x7E])/str_escape_char($1)/eg; $str; }

 view all matches for this distribution


Language-Functional

 view release on metacpan or  search on metacpan

Functional.pm  view on Meta::CPAN

  until          :: (a -> Bool) -> (a -> a) -> a -> a
  until p f x     = if p x then x else until p f (f x)

=cut

sub Until(&&$);
sub Until(&&$) {
  my($p, $f, $x) = @_;
  return $x if $p->($x);
  return Until(\&$p, \&$f, $f->($x));
}

Functional.pm  view on Meta::CPAN

  map              :: (a -> b) -> [a] -> [b]
  map f xs          = [ f x | x <- xs ]

=cut

sub Map(&$) {
  my($f, $xs) = @_;
  tie my @a, 'InfiniteList', sub {
    my($array, $idx) = @_;
    return $f->($xs->[$idx]);
  }, scalar @{$xs};

Functional.pm  view on Meta::CPAN

=cut

# Ha! Before infinite lists simply consisted of:
#  return [grep { $f->($_) } @{$xs}];

sub filter(&$) {
  my($f, $xs) = @_;
  my $pointer = -1;
  tie my @a, 'InfiniteList', sub {
    my($array, $idx) = @_;
    my $debug = 0;

Functional.pm  view on Meta::CPAN

  foldl f z []      = z
  foldl f z (x:xs)  = foldl f (f z x) xs

=cut

sub foldl(&$$) {
  my($f, $z, $xs) = @_;
  map { $z = $f->($z, $_) } @{$xs};
  return $z;
}

Functional.pm  view on Meta::CPAN

  foldl1           :: (a -> a -> a) -> [a] -> a
  foldl1 f (x:xs)   = foldl f x xs

=cut

sub foldl1(&$) {
  my($f, $xs) = @_;
  my $z = shift @{$xs};
  return foldl(\&$f, $z, $xs);
}

Functional.pm  view on Meta::CPAN

                       []   -> []
                       x:xs -> scanl f (f q x) xs)

=cut

sub scanl(&$$) {
  my($f, $q, $xs) = @_;
# Ha! Before infinite lists simply consisted of the elegant:
#  my @return = $q;
#  map { $q = $f->($q, $_); push @return, $q } @{$xs};
#  return [@return];

Functional.pm  view on Meta::CPAN

  scanl1           :: (a -> a -> a) -> [a] -> [a]
  scanl1 f (x:xs)   = scanl f x xs

=cut

sub scanl1(&$) {
  my($f, $xs) = @_;
  my $z = shift @{$xs};
  return scanl(\&$f, $z, $xs);
}

Functional.pm  view on Meta::CPAN

  foldr f z []      = z
  foldr f z (x:xs)  = f x (foldr f z xs)

=cut

sub foldr(&$$) {
  my($f, $z, $xs) = @_;
  map { $z = $f->($_, $z) } reverse @{$xs};
  return $z;
}

Functional.pm  view on Meta::CPAN

  foldr1 f [x]      = x
  foldr1 f (x:xs)   = f x (foldr1 f xs)

=cut

sub foldr1(&$) {
  my($f, $xs) = @_;
  my $z = pop @{$xs};
  return foldr(\&$f, $z, $xs);
}

Functional.pm  view on Meta::CPAN

  scanr f q0 (x:xs) = f x q : qs
                      where qs@(q:_) = scanr f q0 xs

=cut

sub scanr(&$$) {
  my($f, $z, $xs) = @_;
  my @return = $z;
  map { $z = $f->($_, $z); push @return, $z; } reverse @{$xs};
  return [@return];
}

Functional.pm  view on Meta::CPAN

  scanr1 f (x:xs)   = f x q : qs
                      where qs@(q:_) = scanr1 f xs

=cut

sub scanr1(&$) {
  my($f, $xs) = @_;
  my $z = pop @{$xs};
  return scanr(\&$f, $z, $xs);
}

Functional.pm  view on Meta::CPAN

  iterate          :: (a -> a) -> a -> [a]
  iterate f x       = x : iterate f (f x)

=cut

sub iterate(&$) {
  my($f, $x) = @_;
  tie my @a, 'InfiniteList', sub {
    my($array, $idx) = @_;
    return $x if $idx == 0;
    return $f->($array->FETCH($idx-1));

Functional.pm  view on Meta::CPAN

           | p x       = x : takeWhile p xs
           | otherwise = []

=cut

sub takeWhile(&$) {
  my($p, $xs) = @_;
# Ha! Before infinite lists simply consisted of:
#  my @return;
#  push @return, $_ while($_ = shift @{$xs} and $p->($_));
#  return [@return];

Functional.pm  view on Meta::CPAN

           | p x       = dropWhile p xs'
           | otherwise = xs

=cut

sub dropWhile(&$) {
  my($p, $xs) = @_;
# Ha! Before infinite lists simply consisted of:
#  shift @{$xs} while($_ = @{$xs}[0] and $p->($_));
  my $pointer = 0;
  while (1) {

Functional.pm  view on Meta::CPAN

           | otherwise = ([],xs)
                         where (ys,zs) = span p xs'

=cut

sub span(&$) {
  my($p, $xs) = @_;
  my @xs = @{$xs};
  return [takeWhile(\&$p, $xs), dropWhile(\&$p, \@xs)];
}

Functional.pm  view on Meta::CPAN

  break         :: (a -> Bool) -> [a] -> ([a],[a])
  break p        = span (not . p)

=cut

sub break(&$) {
  my($p, $xs) = @_;
  return span(sub { not $p->(@_) }, $xs);
}


Functional.pm  view on Meta::CPAN

  any       :: (a -> Bool) -> [a] -> Bool
  any p      = or  . map p

=cut

sub any(&$) {
  my($p, $xs) = @_;
  my $n = 0;
  my $size = $#{$xs};
  while ($n <= $size) {
    return 1 if $p->($xs->[$n]);

Functional.pm  view on Meta::CPAN

  all  :: (a -> Bool) -> [a] -> Bool
  all p      = and . map p

=cut

sub all(&$) {
  my($p, $xs) = @_;
  my $n = 0;
  my $size = $#{$xs};
  while ($n <= $size) {
    return 0 if not $p->($xs->[$n]);

 view all matches for this distribution


Language-MinCaml

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected,
           $name . "\n" . Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


Lazy-Bool

 view release on metacpan or  search on metacpan

lib/Lazy/Bool.pm  view on Meta::CPAN

use Exporter 'import';

our $VERSION   = '0.06';
our @EXPORT_OK = qw(lzb);

sub lzb(&) {
    my $code = shift;
    __PACKAGE__->new($code);
}

sub new {

 view all matches for this distribution


Lemplate

 view release on metacpan or  search on metacpan

inc/Test/Base.pm  view on Meta::CPAN

        ok $actual eq $expected, $name;
        diag Text::Diff::diff(\$expected, \$actual);
    }
}

sub run(&;$) {
    (my ($self), @_) = find_my_self(@_);
    my $callback = shift;
    for my $block (@{$self->block_list}) {
        $block->run_filters unless $block->is_filtered;
        &{$callback}($block);

 view all matches for this distribution


( run in 2.467 seconds using v1.01-cache-2.11-cpan-49f99fa48dc )