Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: In need of a sequence iterator.

by Zed_Lopez (Chaplain)
on Dec 02, 2004 at 07:08 UTC ( #411670=note: print w/replies, xml ) Need Help??

in reply to In need of a sequence iterator.

Could you show us your recursive code? It'd make me surer I understand the sequence.

Replies are listed 'Best First'.
Re^2: In need of a sequence iterator.
by BrowserUk (Patriarch) on Dec 02, 2004 at 07:51 UTC

    I had to untangle it from it's dependancies with the object it is a method of, but this produces the sequence as show (prior to scrunching and formatting):

    #! perl -slw use strict; sub gen { my( $len, $depth ) = @_; return () unless $len; return map { my $pre = $_; ( $pre, map{ $pre . $_ } gen( $len -1, $depth ) ); } 0 .. $depth - 1; } print for gen( 4, 3 );

    Examine what is said, not who speaks.
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2023-05-31 09:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found