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
| namespace Scripts; | |
| public class Combinatorics | |
| { | |
| public static IEnumerable<IEnumerable<T>> GetPermutations<T>(List<T> input, int i = 0) | |
| { | |
| if (i >= input.Count - 1) | |
| { | |
| yield return input.ToList(); | |
| } |
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
| import time | |
| import datetime | |
| SECONDS_EVERY_FOUR_YEARS = (365 * 4 + 1) * 24 * 3600 | |
| SECONDS_EVERY_YEAR = 365 * 24 * 3600 | |
| SECONDS_EVERY_DAY = 24 * 3600 | |
| DAYS_EVERY_MONTH = [31, (28, 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
| SECONDS_AFTER_FIRST_LEAP_YEAR = SECONDS_EVERY_YEAR * 3 + SECONDS_EVERY_DAY | |
| def _get_numbers_of_days_the_month(m, years_since_last_leap_year): |
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
| #[macro_use] extern crate cpython; | |
| use std::vec::Vec; | |
| use cpython::{PyResult, Python}; | |
| // add bindings to the generated python module | |
| // N.B: names: "libfibonacci" must be the name of the `.so` or `.pyd` file | |
| py_module_initializer!(libfibonacci, initlibfibonacci, PyInit_libfibonacci, |py, m| { | |
| try!(m.add(py, "__doc__", "Fibonacci sequence creation in Rust.")); |
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
| wget -r -k -p -L -R '*.mobi' http://guides.rubyonrails.org/v4.2.4/ | |
| wget -r -k -p -L http://api.rubyonrails.org/v4.2.4/ |
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
| Test grammar: | |
| glurp_grammar! { | |
| R: String => { Optional(R) ~ Char('R') } on {|opt, r| { | |
| if Some(acc) = opt { | |
| push(r); | |
| acc | |
| } else { | |
| String::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
| trait And<B> { | |
| type Result; | |
| fn and(self, rhs: B) -> Self::Result; | |
| } | |
| impl<A, B> And<B> for (A,) { | |
| type Result = (A, B); | |
| fn and(self, rhs: B) -> (A, B) { | |
| (self.0, rhs) | |
| } |
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
| data PushdownAutomaton a b = | |
| Automaton { currentState :: Int | |
| , stack :: [b] | |
| , transitions :: [((Int, Maybe a, Maybe b), [(Int, Maybe b)])] | |
| , acceptStates :: [Int] | |
| } | |
| checkMaybe m h = if m == Nothing then True else m == Just h | |
| eval :: (Eq a, Show a, Eq b) => PushdownAutomaton a b -> [a] -> Bool |
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
| data Side = Adjacent Double | Opposite Double | Hypotenuse Double deriving Show | |
| type Angles = Maybe (Double, Double, Double) | |
| type Sides = Maybe (Double, Double, Double) | |
| data Triangle = Triangle Angles Sides | |
| toDegrees :: Double -> Double | |
| toDegrees rad = rad * 360 / (2 * pi) |
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
| trait HKT<N> { | |
| type C; | |
| type NC; | |
| } | |
| trait Functor<N>: HKT<N> { | |
| fn fmap<F: Fn(&Self::C) -> N>(&self, f: F) -> Self::NC; | |
| } | |
| impl<C, N> HKT<N> for Option<C> { |
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::io::{self, Write}; | |
| use std::fs::File; | |
| use std::path::Path; | |
| use std::rc::Rc; | |
| use std::cmp; | |
| use std::collections::HashMap; | |
| enum TableCell { | |
| TableHeader { | |
| content: String, |
NewerOlder