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
| #![allow(dead_code)] | |
| use customers; // brings module customers to scope, from file ./customers.rs | |
| use rand::Rng; | |
| pub fn waiter_jobs() { | |
| // crate::front::serving::take_order(); // crate points to this crate root | |
| front::serving::take_order(); | |
| front::serving::deliver_to_kitchen(); | |
| crate::front::serving::bring_order(); |
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::HashMap; | |
| fn main() { | |
| // Arrays - fixed size known at compile time | |
| let rust_array = [1, 2, 3]; | |
| // Simple iteration with for-in | |
| for item in rust_array { | |
| println!("{}", item); | |
| } | |
| // Iterate like Go's for-range with enumerate() |
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
| #![allow(dead_code)] | |
| #![allow(unused)] | |
| use std::fs::File; | |
| use std::io::{prelude::*, ErrorKind, Read, BufReader}; | |
| use std::io; | |
| fn main() { | |
| let fname = ".gitignore"; |
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 get_largest<T: PartialOrd + Copy>(v: Vec<T>) -> T { | |
| let mut largest = v[0]; | |
| for item in v { | |
| if largest > item { | |
| largest = item | |
| }; | |
| }; | |
| largest | |
| } |
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
| package main | |
| import ( | |
| "crypto/rand" | |
| "fmt" | |
| "math/big" | |
| "strings" | |
| "time" | |
| ) |
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
| package main | |
| import ( | |
| "crypto/rand" | |
| "fmt" | |
| "math/big" | |
| "strings" | |
| "time" | |
| ) |
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
| #![allow(dead_code)] | |
| // Basic Rust `Iterator` and `DoubleEndedIterator` implementation on nested flattener. | |
| struct Flattener<O> | |
| where | |
| O: Iterator, | |
| O::Item: IntoIterator, | |
| { | |
| outter: O, |
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
| // Generic draw down | |
| fn draw_down<T, U>(points: &[T]) -> U | |
| where | |
| T: Clone + Into<U>, | |
| U: Copy + Default + PartialOrd + std::ops::Sub<Output = U>, | |
| { | |
| if points.len() <= 1 { | |
| return U::default(); | |
| } |
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
| #include <stdio.h> | |
| #define MAXLEN 1000 | |
| /* Avoid confilic with stdio.h */ | |
| int _getline(char line[], int limit); | |
| int main(void) { | |
| char line[MAXLEN]; | |
| int i, j, c, len; |
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
| /* | |
| Rama 9 Sort (rama9sort) | |
| rama9sort is a highly efficient (and sufficient) sorting algorithm that runs in constant time and space (O(1)). | |
| rama9sort got its inspiration from Stalin Sort (another highly efficient algorithm). | |
| rama9sort borrows ideas from Stalin Sort - unwanted/unordered elements are discarded right away from the input, | |
| although rama9sort has some other _unorthodox_ checks to make it more suitable for deployment in Thailand. | |
| The differences from Stalin Sort are: |