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.5 kb
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
1 use 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 {
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
5 ret n + 1
d6b7c96 @graydon Populate tree.
graydon authored
6 } else {
df7f21d @marijnh Reformat for new syntax
marijnh authored
7 if n == 0 {
ce72993 @graydon Reformat source tree (minus a couple tests that are still grumpy).
graydon authored
8 ret ack(m - 1, 1);
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
9 } else {
10 ret ack(m - 1, ack(m, n - 1));
11 }
d6b7c96 @graydon Populate tree.
graydon authored
12 }
13 }
14
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
15 fn main(args: [str]) {
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
16 let args = if os::getenv("RUST_BENCH").is_some() {
17 ["", "12"]
18 } else if args.len() <= 1u {
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();
6f5853f @graydon Libc/os/run/rand/io reorganization. Close #1373. Close #1638.
graydon 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.