trouble returning a value from sub

2022-06-16 Thread Rick Bychowski
if $q.is-prime { @f.push($q); say @f;# [2 2 5] return @f; } else { factors($q, @f); } last; } } } Returns [2 2 5] Nil -- Rick Bychowski The information in this email is confidential and may be

Re: trouble returning a value from sub

2022-06-16 Thread Rick Bychowski
mon Proctor wrote: I think, and I don't have my computer to hand to double check but I think you want a return before your recursive.call to factors passing in @f. When dealing with recursive functions you need to make sure what you're returning back up the stack. On Thu, 16

Re: trouble returning a value from sub

2022-06-16 Thread Rick Bychowski
For example here: https://github.com/manwar/perlweeklychallenge-club/blob/master/challenge-168/rick-bychowski/raku/ch-2.raku I called the recursive function at various points in an if/else statement, but each call was always the very last statement of the branch/routine. Otherwise, even a

Re: trouble returning a value from sub

2022-06-17 Thread Rick Bychowski
eturn if a function has more than a couple of lines. On Thu, 16 Jun 2022, 21:41 Rick Bychowski, mailto:r...@hiranyaloka.com>> wrote: For example here: https://github.com/manwar/perlweeklychallenge-club/blob/master/challenge-168/rick-bychowski/raku/ch-2.raku