[seqfan] Re: Re Nice variant on A030067

M. F. Hasler oeis at hasler.fr
Sun Jan 12 17:48:23 CET 2014


If I may:

The RETURN() or return() or RETURN or return functions/statements are
useless and error-producing since the syntax changes in each version of
Maple. (I exaggerate, of course.) But its true that they are useless
(unless you really have to "bail out" from inside a multiply nested loop or
similar construct) and it's not only simpler, shorter, but plain better to
just remove them, so it should read:

  f:=proc(n) option remember; local t1;
>   if n = 1 then 1
>   elif n mod 2 = 0 then f(n/2)
>   else t1:= f(n-2)-f((n-1)/2);
>   if t1 > 0 then t1 else f(n-2)+f((n-1)/2) fi fi end;


(unless I'm wrong)
See also http://www.maplesoft.com/support/help/Maple/view.aspx?path=return :

1°

One common form of return from a procedure invocation occurs when execution
``falls through'' the end of the statement sequence which makes up the
procedure body, in which case the value of the procedure invocation is the
value of the last statement executed.
2°

The return statement supersedes the RETURN function, which still exists for
backward compatibility. However, use of the RETURN procedure is strongly
discouraged.


Maximilian



More information about the SeqFan mailing list