Hi Everyone,
I've been lurking quite a while, this will be my first post to perl6
users. I've written a lot of short scripts in perl5 for system admin
type stuff at home and work. Lately I'm playing with Raku, which is a
lot of fun. Error reporting is excellent, as is the online documentation.
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 Jun 2022, 18:10 Rick Bychowski, wrote
Hi Rick (and Simon)!
If I change the final (and only) call to `last`, and make it a call to
`exit` instead, the `Nil` disappears. Helpful?
Best Regards, Bill.
On Thu, Jun 16, 2022 at 11:07 AM Simon Proctor wrote:
>
> I think, and I don't have my computer to hand to double check but I think yo
Here is the code:
...
} else {
return factors($q, @f);
}
...
Return the values during recursive calls too.
Output:
[2 2 5]
2
2
5
Simon Proctor @ 2022-06-16 19:07 +01:
> I think, and I don't have my computer to hand to double check but I
> think you want
Yep, the "return factors($q, @f)" fixes it. I've not called a recursion
from anywhere other than the end of a routine, so haven't run into this
issue before. Learned something today!
Thanks to Simon, William and Andinus for your assistance!
- Rick
On 6/16/22 11:07, Simon Proctor wrote:
I thin
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 trai
This is because if there isn't an explicit return the last statement
evaluated is the implied return value.
So the last call (which returns Nil) was your implicit return.
Generally I try and avoid an implicit return if a function has more than a
couple of lines.
On Thu, 16 Jun 2022, 21:41 Rick B