π°οΈ
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::f64; | |
use std::u8; | |
#[allow(dead_code)] | |
fn print_gnostr() { | |
let s = "gnostr"; | |
for byte in s.as_bytes() { | |
print!("{:02X} ", byte); | |
} |
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::env; | |
fn main() { | |
let mut args: Vec<String> = env::args().collect(); | |
let mut verbose_count = 0; | |
let mut output_count = 0; | |
let mut output_files: Vec<String> = Vec::new(); | |
// Simulating command-line arguments (for testing) | |
args.push("-v".to_string()); |
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::env; | |
fn main() { | |
let mut args: Vec<String> = env::args().collect(); | |
let mut verbose = false; | |
let mut output_file: Option<String> = None; | |
args.push("-v".to_string()); | |
args.push("-o".to_string()); | |
args.push("test.txt".to_string()); | |
let mut i = 1; // Start from 1 to skip the executable path |
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
#!/bin/bash | |
# Name of the Makefile to be converted | |
MAKEFILE="Makefile" | |
# Name of the output Justfile | |
JUSTFILE="Justfile" | |
# Check if the Makefile exists | |
if [ ! -f "$MAKEFILE" ]; then |
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 is_prime(n: i32) -> bool { | |
if n <= 1 { | |
return false; | |
} | |
let mut i = 2; | |
while i * i <= n { | |
if n % i == 0 { | |
return false; |
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() { | |
let mut hashmap: HashMap<i32, (i32, i32)> = HashMap::new(); | |
for count in 0..1000 { | |
hashmap.insert(count, (count, count % 13)); | |
} | |
let mut sorted_vec: Vec<(&i32, &(i32, i32))> = hashmap.iter().collect(); |
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 print_moon_phases() { | |
let moon_phases = [ | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", | |
"ππππππππππππ", |
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 gamma(n: f64) -> f64 { | |
// For simplicity, we'll use a basic approximation method. | |
// For higher accuracy, consider using a more sophisticated algorithm or a crate | |
// like `special_function` (if it provides Gamma). | |
// We can use integration techniques like the trapezoidal rule or Simpson's rule for approximation. | |
// Here's a basic trapezoidal rule example: | |
let mut result = 0.0; | |
let a = 0.0; |
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::hash_map::DefaultHasher; | |
use std::hash::{Hash, Hasher}; | |
#[derive(Debug, Clone)] | |
struct HashMap<K, V> | |
where | |
K: Eq + Hash + Clone, | |
V: Clone, | |
{ | |
// Buckets for storing key-value pairs |
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::fs; | |
use std::path::Path; | |
fn main() { | |
let input = "/usr/share/doc"; | |
fn action(path: &str) { println!("\t{}" , path); } | |
fn walk(path: &str) { | |
println!("Listing {} ..." , path); |