When I run the following program to compute the Ackermann function, both the virtual and real calculators crash. I expected to get an error but not a crash.
Try running it for X=4 and Y=3
Tom L
Code:
FNA(M,N)
BEGIN
IF M==0 THEN
RETURN N+1;
END;
IF N==0 THEN
RETURN FNA(M-1,1);
ELSE
RETURN FNA(M-1,FNA(M,N-1));
END;
END;
EXPORT ACKERMANN()
BEGIN
WHILE 1==1 DO
PRINT();
INPUT({X,Y},{'X','Y'});
MSGBOX("Ackermann= "+FNA(X,Y));
GETKEY;
END;
END;
Well, I don't think that the calculators crashes (or I stopped that too early well, after about 10 minutes), perhaps you will have a look at the table
here., which says that the deeply recursive ackerman-function should provide a(4,3)=a(3, 2^65536-3) which is bigger than the estimated amount of atoms in universe. So it should provide an overflow error at some point.
Arno
(09-09-2016 08:24 PM)Arno K Wrote: [ -> ]Well, I don't think that the calculators crashes (or I stopped that too early well, after about 10 minutes), perhaps you will have a look at the table here., which says that the deeply recursive ackerman-function should provide a(4,3)=a(3, 2^65536-3) which is bigger than the estimated amount of atoms in universe. So it should provide an overflow error at some point.
Arno
I know they should get an error, either overflow or out of memory or too many stack levels or something like that but they really do crash. The virtual calc exits and the real one restarts. This should never happen.
Tom L
How long did it run in the VC until it exits? After 30 minutes still running on mine.
Arno
Hello,
I found a bug in the program.
the input functions should have the title as the 2nd arguement, not the {'X', 'Y'} list.
Cyrille
(09-15-2016 10:54 AM)cyrille de brébisson Wrote: [ -> ]Hello,
I found a bug in the program.
the input functions should have the title as the 2nd arguement, not the {'X', 'Y'} list.
Cyrille
Does not change anything, in my opinion ["Title"] means optional:
Syntax:
INPUT(var,[“title”], [“label”], [“help”], [reset_value], [initial_value])
INPUT({vars},[“titles”], [{“labels”}], [{“helps”}], [{reset_values}], [{initial_values}])
var -> {var_name, real, [{pos}]}
var -> {var_name, [allowed_types_matrix], [{pos}]}
var -> {var_name, {choose_items}, [{pos}]}
and, instead of 4 and 3, 3 and 4 runs fine.
Arno
(09-15-2016 10:54 AM)cyrille de brébisson Wrote: [ -> ]Hello,
I found a bug in the program.
the input functions should have the title as the 2nd arguement, not the {'X', 'Y'} list.
Cyrille
It seems to work the way it is but, of course, you know way more about how the calculator works than I do. Would the following code be better? It includes a placeholder comma.
Code:
INPUT({X,Y},,{'X','Y'});
Tom L