Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (33 sloc) 1.006 kb
d1affff @graydon Reliciense makefiles and testsuite. Yup.
graydon authored
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
ea01ee2 @brson Convert 'use' to 'extern mod'. Remove old 'use' syntax
brson authored
11 extern mod std;
d6b7c96 @graydon Populate tree.
graydon authored
12
df7f21d @marijnh Reformat for new syntax
marijnh authored
13 fn ack(m: int, n: int) -> int {
14 if m == 0 {
b355936 @brson Convert ret to return
brson authored
15 return n + 1
d6b7c96 @graydon Populate tree.
graydon authored
16 } else {
df7f21d @marijnh Reformat for new syntax
marijnh authored
17 if n == 0 {
b355936 @brson Convert ret to return
brson authored
18 return ack(m - 1, 1);
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
19 } else {
b355936 @brson Convert ret to return
brson authored
20 return ack(m - 1, ack(m, n - 1));
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
21 }
d6b7c96 @graydon Populate tree.
graydon authored
22 }
23 }
24
edc317b @brson Remove arg vectors from main functions. Stop supporting them.
brson authored
25 fn main() {
26 let args = os::args();
92743dc @msullivan Move the world over to using the new style string literals and types. Cl...
msullivan authored
27 let args = if os::getenv(~"RUST_BENCH").is_some() {
28 ~[~"", ~"12"]
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
29 } else if args.len() <= 1u {
92743dc @msullivan Move the world over to using the new style string literals and types. Cl...
msullivan authored
30 ~[~"", ~"8"]
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
31 } else {
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
32 args
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
33 };
4fec4cd @brson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
34 let n = int::from_str(args[1]).get();
29f32b4 @paulstansifer `m1!{...}` -> `m1!(...)`
paulstansifer authored
35 io::println(fmt!("Ack(3,%d): %d\n", n, ack(3, n)));
518dc52 @brson Reformat
brson authored
36 }
Something went wrong with that request. Please try again.