Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Challenge: Another Infinite Lazy List

by BrowserUk (Pope)
on Mar 18, 2005 at 10:15 UTC ( #440656=note: print w/ replies, xml ) Need Help??


in reply to Re: Challenge: Another Infinite Lazy List
in thread Challenge: Another Infinite Lazy List

You need to make your sorts numeric.

[10:09:10.72] P:\test>copy con junk.pl use strict; use warnings; use overload '""'=>'stringify'; sub stringify { $_[0]->() }; sub make_sub { my ($N) = ( my @f = sort @_ ); return bless sub{ for(;;$N++){ $N % $_ || return $N++ for @f } }; } @ARGV=(2,3,5) unless @ARGV; @ARGV=sort @ARGV; { local $"=", "; local $\="\n"; print "Factors: @ARGV"; foreach (@ARGV) { my $f=make_sub($_); print "F($_) = @{[($f) x 25]}"; } my $o=make_sub(@ARGV); print "R(@ARGV) = @{[($o) x 25]}"; print "----"; } ^Z 1 file(s) copied. [10:09:30.92] P:\test>junk 3 22 111 Factors: 111, 22, 3 F(111) = 111, 222, 333, 444, 555, 666, 777, 888, 999, 1110, 1221, 1332 +, 1443, 1554, 1665, 1776, 1887, 1998, 2109, 2220, 2331, 2442, 2553, 2 +664, 2775 F(22) = 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 242, 264, 286, 3 +08, 330, 352, 374, 396, 418, 440, 462, 484, 506, 528, 550 F(3) = 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51 +, 54, 57, 60, 63, 66, 69, 72, 75 R(111, 22, 3) = 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, + 144, 147, 150, 153, 154, 156, 159, 162, 165, 168, 171, 174, 176, 177 ----

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?


Comment on Re^2: Challenge: Another Infinite Lazy List
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-07-04 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls