Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 26 lines (23 sloc) 0.525 kb
ea01ee2 @brson Convert 'use' to 'extern mod'. Remove old 'use' syntax
brson authored
1 extern mod std;
d6b7c96 @graydon Populate tree.
graydon authored
2
df7f21d @marijnh Reformat for new syntax
marijnh authored
3 fn ack(m: int, n: int) -> int {
4 if m == 0 {
b355936 @brson Convert ret to return
brson authored
5 return n + 1
d6b7c96 @graydon Populate tree.
graydon authored
6 } else {
df7f21d @marijnh Reformat for new syntax
marijnh authored
7 if n == 0 {
b355936 @brson Convert ret to return
brson authored
8 return ack(m - 1, 1);
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
9 } else {
b355936 @brson Convert ret to return
brson authored
10 return ack(m - 1, ack(m, n - 1));
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
11 }
d6b7c96 @graydon Populate tree.
graydon authored
12 }
13 }
14
92743dc @msullivan Move the world over to using the new style string literals and types. Cl...
msullivan authored
15 fn main(args: ~[~str]) {
16 let args = if os::getenv(~"RUST_BENCH").is_some() {
17 ~[~"", ~"12"]
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
18 } else if args.len() <= 1u {
92743dc @msullivan Move the world over to using the new style string literals and types. Cl...
msullivan authored
19 ~[~"", ~"8"]
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
20 } else {
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
21 args
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
22 };
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
23 let n = int::from_str(args[1]).get();
29f32b4 @paulstansifer `m1!{...}` -> `m1!(...)`
paulstansifer authored
24 io::println(fmt!("Ack(3,%d): %d\n", n, ack(3, n)));
518dc52 @brson Reformat
brson authored
25 }
Something went wrong with that request. Please try again.