blob: 7064c1cc8c5e73cc3cc111decfc8ae2736e4466b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use crate::ast::Value;
use std::collections::HashMap;
pub struct Builtins {}
impl Builtins {
pub fn new() -> HashMap<String, Value> {
let mut map = HashMap::new();
map.insert("+".to_string(), Value::Prim("+".to_string()));
map
}
}
pub fn plus(v: Value) -> Value {
match v {
Num(i) => Lam(gensym(),
}
}
pub fn builtins(sym: &String) -> Option<Box<dyn Fn(Value) -> Value>> {
match sym.as_str() {
"+" => Some(Box::new(plus)),
_ => None,
}
}
|