Skip to content

Commit

Permalink
add iter method
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Nov 1, 2021
1 parent d86bdc4 commit 326ae3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ notify = "4.0.17"
walkdir = "2"
hex = "0.4.3"
rpds = "0.10.0"
im_ternary_tree = "0.0.1-a2"
im_ternary_tree = "0.0.1-a3"
# im_ternary_tree = { path = "/Users/chen/repo/calcit-lang/ternary-tree" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/builtins/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ pub fn call_try(expr: &CalcitItems, scope: &CalcitScope, file_ns: &str, call_sta
let err_data = Calcit::Str(failure.msg.to_owned().into_boxed_str());
match f {
Calcit::Fn(_, def_ns, _, def_scope, args, body) => {
let values = TernaryTreeList::from(&vec![err_data]);
let values = TernaryTreeList::from(&[err_data]);
runner::run_fn(&values, &def_scope, &args, &body, &def_ns, call_stack)
}
Calcit::Proc(proc) => builtins::handle_proc(&proc, &TernaryTreeList::from(&vec![err_data]), call_stack),
Calcit::Proc(proc) => builtins::handle_proc(&proc, &TernaryTreeList::from(&[err_data]), call_stack),
a => CalcitErr::err_str(format!("try expected a function handler, got: {}", a)),
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/runner/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ fn process_list_call(

(_, Some(Calcit::Fn(f_name, _name_ns, _id, _scope, f_args, _f_body))) => {
check_fn_args(&f_args, &args, file_ns, &f_name, &def_name, check_warnings);
let mut ys = TernaryTreeList::from(&vec![head_form]);
let mut ys = TernaryTreeList::from(&[head_form]);
for a in &args {
let (form, _v) = preprocess_expr(a, scope_defs, file_ns, check_warnings, call_stack)?;
ys = ys.push(form);
}
Ok((Calcit::List(ys), None))
}
(_, _) => {
let mut ys = TernaryTreeList::from(&vec![head_form]);
let mut ys = TernaryTreeList::from(&[head_form]);
for a in &args {
let (form, _v) = preprocess_expr(a, scope_defs, file_ns, check_warnings, call_stack)?;
ys = ys.push(form);
Expand Down Expand Up @@ -454,7 +454,7 @@ pub fn preprocess_each_items(
check_warnings: &RefCell<Vec<String>>,
call_stack: &CallStackVec,
) -> Result<Calcit, CalcitErr> {
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
for a in args {
let (form, _v) = preprocess_expr(a, scope_defs, file_ns, check_warnings, call_stack)?;
xs = xs.push(form);
Expand All @@ -472,7 +472,7 @@ pub fn preprocess_defn(
call_stack: &CallStackVec,
) -> Result<Calcit, CalcitErr> {
// println!("defn args: {}", primes::CrListWrap(args.to_owned()));
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
match (args.get(0), args.get(1)) {
(Some(Calcit::Symbol(def_name, def_name_ns, at_def, _)), Some(Calcit::List(ys))) => {
let mut body_defs: HashSet<Box<str>> = scope_defs.to_owned();
Expand Down Expand Up @@ -550,7 +550,7 @@ pub fn preprocess_call_let(
check_warnings: &RefCell<Vec<String>>,
call_stack: &CallStackVec,
) -> Result<Calcit, CalcitErr> {
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut body_defs: HashSet<Box<str>> = scope_defs.to_owned();
let binding = match args.get(0) {
Some(Calcit::Nil) => Calcit::Nil,
Expand All @@ -559,7 +559,7 @@ pub fn preprocess_call_let(
check_symbol(sym, args, check_warnings);
body_defs.insert(sym.to_owned());
let (form, _v) = preprocess_expr(a, &body_defs, file_ns, check_warnings, call_stack)?;
Calcit::List(TernaryTreeList::from(&vec![ys[0].to_owned(), form]))
Calcit::List(TernaryTreeList::from(&[ys[0].to_owned(), form]))
}
(a, b) => {
return Err(CalcitErr::use_msg_stack(
Expand Down Expand Up @@ -604,7 +604,7 @@ pub fn preprocess_quote(
_scope_defs: &HashSet<Box<str>>,
_file_ns: &str,
) -> Result<Calcit, CalcitErr> {
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
for a in args {
xs = xs.push(a.to_owned());
}
Expand All @@ -620,7 +620,7 @@ pub fn preprocess_defatom(
check_warnings: &RefCell<Vec<String>>,
call_stack: &CallStackVec,
) -> Result<Calcit, CalcitErr> {
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
for a in args {
// TODO
let (form, _v) = preprocess_expr(a, scope_defs, file_ns, check_warnings, call_stack)?;
Expand All @@ -639,7 +639,7 @@ pub fn preprocess_quasiquote(
check_warnings: &RefCell<Vec<String>>,
call_stack: &CallStackVec,
) -> Result<Calcit, CalcitErr> {
let mut xs: CalcitItems = TernaryTreeList::from(&vec![Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
let mut xs: CalcitItems = TernaryTreeList::from(&[Calcit::Syntax(head.to_owned(), head_ns.to_owned().into())]);
for a in args {
xs = xs.push(preprocess_quasiquote_internal(a, scope_defs, file_ns, check_warnings, call_stack)?);
}
Expand Down

0 comments on commit 326ae3a

Please sign in to comment.