Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 37 lines (33 sloc) 1.055 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
220bf41 @nagisa Cleanup getenv from tests and benchmarks
nagisa authored
11 use std::env;
206ab89 @pcwalton librustc: Stop reexporting the standard modules from prelude.
pcwalton authored
12
7d941fa @nagisa Replace some uses of deprecated os functions
nagisa authored
13 fn ack(m: i64, n: i64) -> i64 {
df7f21d @marijnh Reformat for new syntax
marijnh authored
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() {
7d941fa @nagisa Replace some uses of deprecated os functions
nagisa authored
26 let mut args = env::args();
220bf41 @nagisa Cleanup getenv from tests and benchmarks
nagisa authored
27 let args = if env::var_os("RUST_BENCH").is_some() {
4348e23 @richo std: Remove String's to_owned
richo authored
28 vec!("".to_string(), "12".to_string())
7d941fa @nagisa Replace some uses of deprecated os functions
nagisa authored
29 } else if args.len() <= 1 {
4348e23 @richo std: Remove String's to_owned
richo authored
30 vec!("".to_string(), "8".to_string())
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
31 } else {
7d941fa @nagisa Replace some uses of deprecated os functions
nagisa authored
32 args.collect()
c53d0a0 @brson bench: Update shootout-ackermann for performance
brson authored
33 };
7d8d06f @alexcrichton Remove deprecated functionality
alexcrichton authored
34 let n = args[1].parse().unwrap();
409182d @alexcrichton Update the compiler to not use printf/printfln
alexcrichton authored
35 println!("Ack(3,{}): {}\n", n, ack(3, n));
518dc52 @brson Reformat
brson authored
36 }
Something went wrong with that request. Please try again.