Hello Jacinta,
Perl6 code should be much simpler than what you are trying. There is no
need to use a state variable or a binding.
I'm not sure how to use a maximum in the sequence, so I didn't.
The Fibonacci sequence can be generated in a single line as
1, 1, &[+] ... *
or as
1, 1, *+* ...
On Thu, Dec 12, 2013 at 02:05:35PM +1100, Jacinta Richardson wrote:
:sub MAIN($terms = 35, $maximum = 4_000_000) {
: my @sequence = gather for fibonacci($maximum) -> $number {
: state $count = 0;
: take $number if $number < $maximum && $count++ < $terms;
:
Hi Jacinta,
I get a bit further with my build of Perl 6, which at least runs:
% perl6 fib.pl
0
Are you maybe using an old Perl6? Try:
% perl6 -e'say $*PERL'
("name" => "rakudo", "compiler" => {"name" => "rakudo", "ver" =>
"2013.11-22-g262e600", "release-number" => "", "build-date" =>
"2013-12-0
G'day folk,
I'm slowing working through some basic exercises to get a feel for Perl
6. I'm currently trying to create a fibonacci sequence stopping at a
maximum value, or a set number of terms...
I've written this:
use v6;
sub MAIN($terms = 35, $maximum = 4_000_000) {
my @seq