in reply to Re^2: cross combinations
in thread cross combinations

The p6 solution above has something yours doesn't, take and gather. By default (at least last week ;) ) take and gather are lazy.
Sure, take and gather are lazy. But since you need the entire list anyway, it doesn't really matter, does it? Lazy lists are nice if you don't need the entire thing - if you need the entire thing, it hardly matters.

I still don't see the point of the various Perl6 solutions. The solution you present above doesn't have any benefits of the Perl5 solution - it just uses a different syntax, not even syntax that's significantly shorter, or easier to understand (it isn't harder or longer either - just different). It doesn't score on the "see how much easier this problem is in perl6" scale.

Perl --((8:>*

Replies are listed 'Best First'.
Re^4: cross combinations
by eric256 (Parson) on Oct 28, 2005 at 18:10 UTC

    Who said anything about this being the easier solution? My post was just to show you that it could be done the same in pugs. You didn't present any point except that yours was shorter so i was pointing out that isn't true. BTW lazy has a different advantage. If its lazy you get it as you need it, so you don't spend time processing until you get to stuff you need. So even if you need it all this can spread the processing time out instead of one giant load period in the begining. when all you are doing is printing out the matches that doesn't help much, but if you were doing something else it could be very helpful.


    ___________
    Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;
Re^4: cross combinations
by tilly (Archbishop) on Oct 29, 2005 at 03:04 UTC
    Lazy lists are nice if you don't need the entire thing - if you need the entire thing, it hardly matters.

    I heartily disagree. If the list is large and you don't need the entire thing at once, then being lazy saves you a lot of memory, and can be the difference between getting an answer a minute later, and having your program crash. (For instance that's why you want to use while to loop through a large file rather than for.)

    Combining lists quickly creates a combinatorial explosion where you really don't want it all in memory if you don't need it there.