RosettaCodeData/Task/Ackermann-function/FutureBasic/ackermann-function.basic

27 lines
608 B
Plaintext

include "NSLog.incl"
local fn Ackerman( m as NSInteger, n as NSInteger ) as NSInteger
NSInteger result
select
case m == 0 : result = ( n + 1 )
case n == 0 : result = fn Ackerman( ( m - 1 ), 1 )
case else : result = fn Ackerman( ( m - 1 ), fn Ackerman( m, ( n - 1 ) ) )
end select
end fn = result
NSInteger m, n
CFMutableStringRef mutStr
mutStr = fn StringWithCapacity( 0 )
for m = 0 to 3
for n = 0 to 9
StringAppendString( mutStr, fn StringWithFormat( @"fn Ackerman( %ld, %ld ) = %ld\n", m, n, fn Ackerman( m, n ) ) )
next
next
NSLog( @"%@", mutStr )
HandleEvents