linkspace/experimental/
mod.rs1pub mod tap_hashes;
2pub mod tree;
3
4use crate::prelude::*;
5use linkspace_core::abe::{eval::eval, parse_abe};
6
7pub use linkspace_core::abe::ablist::ABList;
9
10pub fn lka_eval_list(expr: &str, strict: bool, scope: &dyn LkEnv) -> LkResult<ABList> {
11 let expr = parse_abe(expr, strict)?;
12 let scope = scope.as_scope();
13 Ok(eval(&scope.as_dyn(), &expr)?)
14}
15
16pub use linkspace_core::abe::ast::Ctr;
17pub fn lka_eval_parts(
18 strict: bool,
19 expr: &str,
20 cb: &mut dyn FnMut(Ctr, &[u8]) -> bool,
21 scope: &dyn LkEnv,
22) -> LkResult<bool> {
23 let expr = parse_abe(expr, strict)?;
24 let scope = scope.as_scope();
25 let ablist = eval(&scope.as_dyn(), &expr)?;
26 for (ctr, bytes) in ablist.as_slice() {
27 if cb(*ctr, bytes) {
28 return Ok(true);
29 }
30 }
31 Ok(false)
32}
33pub fn lka_split_parts(
34 expr: &str,
35 strict: bool,
36 cb: &mut dyn FnMut(Ctr, &str) -> bool,
37) -> LkResult<bool> {
38 use linkspace_core::abe::abtxt::split_parts_str;
39 for r in split_parts_str(expr, strict) {
40 let (c, st) = r?;
41 if cb(c, st) {
42 return Ok(true);
43 }
44 }
45 Ok(false)
46}