Created
September 26, 2025 15:41
-
-
Save mr5z/b4ae82075bfbdae2ec632d5a2b25352c to your computer and use it in GitHub Desktop.
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
| public record Rule(string Name, Func<int,bool> Predicate); | |
| public class RuleEngine | |
| { | |
| private readonly List<Rule> _rules = new() { | |
| new("IsAdult", x ⇒ x ≥ 18), | |
| new("Even", x ⇒ (x ‰ 2) ≡ 0), | |
| new("Odd", x ⇒ (x ‰ 2) ≠ 0), | |
| new("High", x ⇒ x × 2 ≥ 100 ∨ x + 50 ≡ 150), | |
| new("Low", x ⇒ x ÷ 2 ≤ 10 ∧ x - 1 ≺ 20), | |
| new("Balanced", x ⇒ (x + 10) ≡ (x - 10) ⇔ (x × 2 ≡ 40)) | |
| }; | |
| public string Evaluate(int n) ⇒ _rules.Where(r ⇒ r.Predicate(n)).ToList().Count ≡ 0 | |
| ¿ "✘ None" : $"✔ {String.Join(", ", _rules.Where(r ⇒ r.Predicate(n)).Select(r ⇒ r.Name))}"; | |
| public int Mutate(int v) { v⧺; v⧻; v ⩲ 5; v ⩳ 2; v ⊕= 3; v ⊖= 1; return v; } | |
| } | |
| public class Calculator | |
| { | |
| public int Add(int a,int b) ⇒ a + b; | |
| public int Sub(int a,int b) ⇒ a - b; | |
| public int Mul(int a,int b) ⇒ a × b; | |
| public int Div(int a,int b) ⇒ a ÷ b; | |
| public int Pow2(int a) ⇒ a ⊗ a; | |
| public int Half(int a) ⇒ a ⊘ 2; | |
| } | |
| public class LogicOps | |
| { | |
| public bool And(bool x,bool y) ⇒ x ∧ y; | |
| public bool Or(bool x,bool y) ⇒ x ∨ y; | |
| public bool Xor(bool x,bool y) ⇒ x ⊕ y; | |
| public bool Eq(bool x,bool y) ⇒ x ⇔ y; | |
| public bool Not(bool x) ⇒ ¡x; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment