26 lines
614 B
Rust
26 lines
614 B
Rust
use std::fmt;
|
|
|
|
use crate::{map::Map, symbol::Symbol};
|
|
|
|
pub enum Val {
|
|
Number(f64),
|
|
Function {
|
|
inputs: Vec<Symbol>,
|
|
outputs: Vec<Symbol>,
|
|
run: Box<dyn FnMut(Map<Val>) -> Val>,
|
|
},
|
|
Map(Map<Val>),
|
|
}
|
|
|
|
impl fmt::Debug for Val {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::Number(n) => write!(f, "{n:?}"),
|
|
Self::Function {
|
|
inputs, outputs, ..
|
|
} => write!(f, "fn([{}], [{}]", inputs.join(" "), outputs.join(" ")),
|
|
Self::Map(map) => write!(f, "{map:?}"),
|
|
}
|
|
}
|
|
}
|