From b5dbec1a97056d59875aeae9d6fbca556fa7fefe Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Tue, 10 Nov 2026 09:51:34 -0600 Subject: feat: ex6_7 commit bee14556fc962f0e0c0b3ef2a0b1658a50529aec Author: Brad Clawsie Date: Tue Nov 10 09:43:16 2026 -0600 feat: ex6_7 --- ex6_7/Cargo.lock | 7 +++++++ ex6_7/Cargo.toml | 6 ++++++ ex6_7/src/main.rs | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 ex6_7/Cargo.lock create mode 100644 ex6_7/Cargo.toml create mode 100644 ex6_7/src/main.rs diff --git a/ex6_7/Cargo.lock b/ex6_7/Cargo.lock new file mode 100644 index 0000000..8cd3cf7 --- /dev/null +++ b/ex6_7/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ex6_7" +version = "0.1.0" diff --git a/ex6_7/Cargo.toml b/ex6_7/Cargo.toml new file mode 100644 index 0000000..cc7c66b --- /dev/null +++ b/ex6_7/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ex6_7" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/ex6_7/src/main.rs b/ex6_7/src/main.rs new file mode 100644 index 0000000..679142c --- /dev/null +++ b/ex6_7/src/main.rs @@ -0,0 +1,24 @@ +// instead of following study guide, just try fizzbuzz + +fn fb(n: u32) -> Vec { + if n < 1 { + panic!("n is less than 1"); + } + let f = |n: u32| -> String { + if n % 15 == 0 { + return "fizzbuzz".to_string(); + } + if n % 5 == 0 { + return "fizz".to_string(); + } + if n % 3 == 0 { + return "buzz".to_string(); + } + ToString::to_string(&n) + }; + (1..n+1).map(|n| f(n)).collect() +} + +fn main() { + println!("{:?}", fb(25)); +} -- cgit v1.2.3