Skip to content

Instantly share code, notes, and snippets.

@eventhelix
Created May 7, 2022 17:45
Show Gist options
  • Save eventhelix/87f39760326d89742d82b0017bbb62ba to your computer and use it in GitHub Desktop.
Save eventhelix/87f39760326d89742d82b0017bbb62ba to your computer and use it in GitHub Desktop.
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