[seqfan] Re: RETURN in Maple
Heinz, Alois
alois.heinz at hs-heilbronn.de
Sun Jan 12 23:08:21 CET 2014
It seems that the error was caused by something else, please read
the other thread also:
http://list.seqfan.eu/pipermail/seqfan/2014-January/012270.html
"Okay, I see what happened... I already had an f := proc(n) on the
page when
I pasted the code, so I changed the name to g := proc(n). Problem was, I
forgot to apply the changes to the internal 'f's... I guess it's a wonder
that it ran at all!
Oh well, at least this oversight initiated an informative discussion...
still, this is perhaps a sign that I should spend more time with fractals,
where my siliest mistakes sometimes produce the most amazing images...
Regards, Russell"
nothing to add.
Best regards, Alois
Am 12.01.2014 22:59, schrieb Brendan McKay:
> Folks,
>
> It is quite impossible that Maple will get rid of the concept of
> returning a value. They are just phasing out “RETURN(x)” in
> favour of “return x”. That is, the spelling changed and it
> became a statement rather than a function. The “strong
> discouragement” about RETURN is because it is obsolete.
>
> So the code can look like this:
>
> f:=proc(n) option remember; local t1;
> if n = 1 then return 1;
> elif n mod 2 = 0 then return f(n/2);
> else t1:= f(n-2)-f((n-1)/2);
> if t1 > 0 then return t1 else return f(n-2)+f((n-1)/2); fi; fi; end;
>
>
> If that gives wrong values in Maple 17, either there is a bug in the
> code or a bug in Maple 17. I can’t check; I only have Maple 16.
>
> I severely don’t like the new warning. It is much a stronger claim
> than anyone has shown to be true. Much better would be to say
> “Newer versions of Maple prefer ‘return x’ rather than ‘RETURN(x)’.”.
> Even better, just silently replace “RETURN" by “return”. The
> extra parentheses shouldn’t make any difference and only people
> stuck with Maple 5 or earlier will have trouble.
>
> Brendan.
>
More information about the SeqFan
mailing list