From f03541d056ca149848e1d11b7e12d69dfff699d9 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sun, 12 Feb 2023 15:24:59 +0100 Subject: [PATCH] potential task formulation --- src/expression_parser.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/expression_parser.rs b/src/expression_parser.rs index 0fc4a2f..8e6958a 100644 --- a/src/expression_parser.rs +++ b/src/expression_parser.rs @@ -155,11 +155,19 @@ impl Expression { let mut brace_groups_texts: Vec = Vec::new(); let mut children: Vec = Vec::new(); + // 1 brace group per possible combination, by default, this is only (), so 1 iteration. + // This is still O(n¹) for brace_group in brace_groups { for pair in brace_group { let text = &expression_text[pair.0..pair.1 + 1]; let text = &text[1..text.len() - 1]; + #[cfg(debug_assertions)] dbg!(text); + brace_groups_texts.push(text.to_string()); + // we have the expression_text, now we just need to get the task until we can + // pass these parameters into Expression::new(). This is the recursive part. + let possible_task = &expression_text[..pair.0].chars().rev().collect::(); + dbg!(possible_task); } } } @@ -182,18 +190,3 @@ impl Expression { println!("{}", self.text); } } - -enum Brace { - Open(char), - Closed(char), -} - -impl Brace { - pub fn new(c: char) -> Option { - match c { - '{' | '[' | '(' => Some(Brace::Open(c)), - '}' | ']' | ')' => Some(Brace::Closed(c)), - _ => None, - } - } -} \ No newline at end of file