Created
May 7, 2022 17:45
-
-
Save eventhelix/87f39760326d89742d82b0017bbb62ba to your computer and use it in GitHub Desktop.
This file contains 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
pub enum Number { | |
Integer (usize), | |
Real (f64), | |
Complex(f64, f64) | |
} | |
pub fn double (num: Number) -> Number { | |
match num { | |
Number::Integer (n) => Number::Integer(n+n), | |
Number::Real (n) => Number::Real (n+n), | |
Number::Complex(r,i) => Number::Complex(r+r, i+i) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment