Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Variant permutation

by runrig (Abbot)
on Aug 30, 2003 at 17:28 UTC ( #287937=note: print w/replies, xml ) Need Help??

in reply to Variant permutation

Here is a version of Re (tilly) 1 (perl): What Happened...(perils of porting from c):
#!/usr/bin/perl use strict; use warnings; my @array = ( [1..3],['a'..'b'],['A'..'C'] ); my @prev_value; nested_for( sub { if (@prev_value) { my $diff; for (0..$#prev_value) { if ($prev_value[$_] ne $_[$_]) { $diff = $_; last; } } if (defined $diff) { for (reverse $diff..$#prev_value) { print " ", @prev_value[0..$_]; } print "\n"; } else { print " "; } } print @_; @prev_value = @_[0..$#_-1]; }, reverse @array); sub nested_for { ret_iter(@_)->(); } sub ret_iter { my $fn = shift; my $range = shift; my $sub = sub { $fn->(@_, $_) for @$range }; return @_ ? ret_iter($sub, @_) : $sub; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287937]
[ksbehal]: I need to test a .pl file for unit testing and integration testing. I tried to use the Test::More but when I am doing require_ok, it is executing the given script which i do not want.. any way out??

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-01-24 12:40 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (204 votes). Check out past polls.