Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
added ackermann test (#12), needs massive optimizations, but technica…
Browse files Browse the repository at this point in the history
…lly, it works
  • Loading branch information
Electrux committed Dec 2, 2019
1 parent ce3d1f6 commit 7bc9e7e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ackermann.et
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env et

import std.vec;

# TODO: optimize allocations
fn ack( m, n ) {
if m == 0 { return n + 1; }
if n == 0 { return ack( m - 1, 1 ); }
return ack( m - 1, ack( m, n - 1 ) );
}

M = 4;
N = 10;
if args.len() > 1 {
M = 2;
N = 5;
}
for m = 0; m < M; m += 1 {
for n = 0; n < N; n += 1 {
println( 'A(', m, ', ', n, ') = ', ack( m, n ) );
}
}

0 comments on commit 7bc9e7e

Please sign in to comment.