diff --git a/.idea/misc.xml b/.idea/misc.xml
index f1a0458..7824de4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -44,6 +44,7 @@
+
diff --git a/.idea/rust.iml b/.idea/rust.iml
index 2ed216a..952a6f9 100644
--- a/.idea/rust.iml
+++ b/.idea/rust.iml
@@ -177,6 +177,10 @@
+
+
+
+
@@ -204,6 +208,7 @@
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7ce4a57..c359113 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,23 +15,28 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -65,7 +70,6 @@
@@ -126,10 +131,10 @@
false
-
-
-
-
+
+
+
+
@@ -172,18 +177,35 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -193,7 +215,7 @@
-
+
@@ -227,7 +249,7 @@
-
+
@@ -256,16 +278,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -286,6 +298,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -305,11 +327,11 @@
+
-
@@ -346,11 +368,11 @@
-
+
-
-
+
+
@@ -358,7 +380,7 @@
-
+
@@ -366,7 +388,7 @@
-
+
@@ -380,36 +402,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -587,13 +579,6 @@
-
-
-
-
-
-
-
@@ -802,8 +787,8 @@
-
-
+
+
@@ -813,8 +798,29 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/old_lady_who_swallowed_a_fly/Cargo.toml b/old_lady_who_swallowed_a_fly/Cargo.toml
new file mode 100644
index 0000000..c56eb95
--- /dev/null
+++ b/old_lady_who_swallowed_a_fly/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "old_lady_who_swallowed_a_fly"
+version = "0.1.0"
+authors = ["Timothy Warren "]
+edition = "2018"
+
+[dependencies]
diff --git a/old_lady_who_swallowed_a_fly/src/main.rs b/old_lady_who_swallowed_a_fly/src/main.rs
new file mode 100644
index 0000000..83d2605
--- /dev/null
+++ b/old_lady_who_swallowed_a_fly/src/main.rs
@@ -0,0 +1,74 @@
+#[derive(Clone, Debug)]
+enum Flow { Every, Once, End }
+use Flow::*;
+
+#[derive(Clone, Debug)]
+struct Verse {
+ animal: String,
+ flow_type: Flow,
+ aside: String,
+}
+
+impl Verse {
+ pub fn new(animal: &str, flow_type: Flow, aside: &str) -> Verse {
+ Verse {
+ animal: String::from(animal),
+ flow_type,
+ aside: String::from(aside)
+ }
+ }
+}
+
+fn swallowed_a(verse: &Verse) {
+ println!("\nThere was an old lady who swallowed a {};\n{}", verse.animal, verse.aside);
+}
+
+fn cumulative_refrain(slice: &[Verse]) {
+ for n in 0..slice.len() {
+ let repeat = &slice[n];
+
+ if n != (slice.len() - 1) {
+ let prev = &slice[n + 1];
+ println!("\tShe swallowed the {} to catch the {};", repeat.animal, prev.animal);
+
+ if let Every = prev.flow_type {
+ println!("\t{}", prev.aside);
+ }
+ }
+ }
+}
+
+fn print_verses(animals: [Verse;8]) {
+ for index in 0..animals.len() {
+ let verse = &animals[index];
+ swallowed_a(&verse);
+
+ // End early on the last verse
+ if let End = verse.flow_type {
+ return
+ };
+
+ if index > 0 {
+ let slice = &animals[0..=index];
+ let mut slice = slice.to_vec();
+ slice.reverse();
+
+ cumulative_refrain(&slice);
+ }
+ }
+}
+
+fn main() {
+ let animals = [
+ Verse::new("fly", Every, "I don't know why she swallowed a fly - perhaps she'll die!"),
+ Verse::new("spider", Every, "That wriggled and jiggled and tickled inside her!"),
+ Verse::new("bird", Once, "How absurd to swallow a bird!"),
+ Verse::new("cat", Once, "Imagine that! She swallowed a cat!"),
+ Verse::new("dog", Once, "What a hog, to swallow a dog!"),
+ Verse::new("goat", Once, "She just opened her throat and swallowed a goat!"),
+ Verse::new("cow", Once, "I don't know how she swallowed a cow!"),
+ Verse::new("horse", End, "She's dead of course!"),
+ ];
+
+ print_verses(animals);
+}