This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let (cnt, sum) = sieve(1000000).iter() | |
| .fold((0u, 0u), |a, b| { | |
| let (cnt, sum) = a; | |
| (cnt + 1, sum + *b) | |
| }); | |
| println!("{}", sum as f32 / cnt as f32); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(unboxed_closures)] | |
| fn main() { | |
| let x = from_str::<int>(std::os::args()[1].as_slice()).unwrap(); | |
| let n = Bounce::Incomplete(x).execute(|n| { | |
| match n { | |
| n if n < 1 => Bounce::Fault("Value out of range."), | |
| 1i => Bounce::Complete(n), | |
| n => Bounce::Incomplete(n - 1i), | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(unboxed_closures)] | |
| use Bounce::{Process, Result}; | |
| fn main() { | |
| let x: int = from_str(std::os::args()[1].as_slice()).unwrap(); | |
| let result = Process(box move || is_even(x)).execute(); | |
| println!("{}", if result { "even" } else { "odd" }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate chrono; | |
| pub mod expiring_cache { | |
| use chrono::{DateTime, Duration, UTC}; | |
| use std::collections::HashMap; | |
| use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
| use std::hash::Hash; | |
| pub struct ExpiringCache<Key, Value> where Key: Eq + Hash { | |
| expiry: Duration, // cache endurance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::iter::iterate; | |
| use std::num::Float; | |
| use std::sync::Future; | |
| fn main() { | |
| if let Some(n) = read_uint(1) { | |
| let sum_of_primes = { | |
| let block_size = if n > 999 { n / 20 } else { n }; | |
| let mut futures = Vec::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashSet; | |
| use std::hash::{Hash, Hasher}; | |
| use std::collections::hash_state::HashState; | |
| fn main() { | |
| if let Some(content) = { | |
| let args = std::os::args(); | |
| if args.len() == 2 { | |
| Some(args[1].to_string()) | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace ConsoleApplication2 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var propertyValue = GetValidDecimalInput(); | |
| var propertyTax = PropertyAssessment(propertyValue) * 0.0064m; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using System.Net; | |
| using System.Text.RegularExpressions; | |
| namespace Computus | |
| { | |
| class Program | |
| { | |
| static Regex NodePattern = new Regex(@"<pre>.*?</pre>", RegexOptions.IgnoreCase|RegexOptions.Singleline); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct TipResult { | |
| amt: f64, | |
| tip: f64, | |
| } | |
| fn main() { | |
| let args: Vec<_> = std::env::args().collect(); | |
| let tip = match &args[..] { | |
| [_, ref amt] => get_tip(amt.parse().ok(), Some(0.15f64)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum TestEnum { | |
| DataA { f: String, l: String }, | |
| DataB { n: String }, | |
| } | |
| impl std::fmt::Display for TestEnum { | |
| fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { | |
| match self { | |
| &TestEnum::DataA { ref f, ref l } => write!(fmt, "{}, {}", l, f), | |
| &TestEnum::DataB { ref n } => fmt.write_str(&n), |