http://qs1969.pair.com?node_id=411670


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