@@ -30,8 +30,8 @@ fn reduce($arr, $fn) = if !isEmpty($arr) then fold(tail($arr), $arr.0, $fn) else
30
30
fn filterMap($arr, $fn) = flatMap($arr, |$el| { $r = $fn($el); if $r != filterMap::skip then [$r] else [] });
31
31
filterMap::skip = symbol("filterMap::skip");
32
32
33
- fn find($arr, $fn) = foldUntil($arr, null, |$acc, $el| if $fn($el) then true:$el else false:null);
34
- fn some($arr, $fn) = foldUntil($arr, false, |$acc, $el| if $fn($el) then true:true else false:false);
33
+ fn find($arr, $fn) = foldUntil($arr, null, |$acc, $el| if $fn($el) then true:$el else false:null);
34
+ fn some($arr, $fn) = foldUntil($arr, false, |$acc, $el| if $fn($el) then true:true else false:false);
35
35
fn every($arr, $fn) = !some($arr, |$el| !$fn($el));
36
36
37
37
fn contains($arr, $needle) = some($arr, |$el| $el == $needle);
@@ -59,9 +59,8 @@ fn join($strs, $sep) =
59
59
else if len($strs) == 1 then $strs.0
60
60
else concat([ $strs.0 ] + map(tail($strs), |$str| $sep + $str));
61
61
62
- // Array tag extraction with multiple values (`$tagged->$tag` can be used for a single value)
63
- fn t::multi($tagged, $tag) = $tagged | filter(|$kv| $kv.0 == $tag) | map(|$kv| $kv.1);
64
-
62
+ // Array tag extraction with multiple values (`$tagged->tag` can be used for a single value)
63
+ fn t::multi($tagged, $tag) = $tagged | filter(|[$k, _]| $k == $tag) | map(|[_, $v]| $v);
65
64
66
65
//
67
66
// Dev utilities
@@ -73,12 +72,11 @@ fn assert::eq($a, $b) = ($a == $b) || throw("Not equal: "+$a+" != "+$b+"");
73
72
fn assert::msg($bool, $msg) = $bool || throw($msg);
74
73
75
74
// Scope inspection
76
- dyn fn env::pretty() = env() | map(|$kv | $kv.0 +" = "+pretty($kv.1 )+" // "+typeof($kv.1 )) | join("\n\n")| symbol();
77
- dyn fn env::repr() = env() | filter(|$kv | !isFunction($kv.1 )) | map(|$kv | $kv.0 +" = "+repr($kv.1 )+"; // "+typeof($kv.1 )) | join("\n\n") | symbol();
78
- dyn fn env::debug() = env() | map(|$kv | $kv.0 +" = "+_debug_nonfn($kv.1 )) | join("\n\n") | symbol();
75
+ dyn fn env::pretty() = env() | map(|[$k:$v] | $k +" = "+pretty($v )+" // "+typeof($v )) | join("\n\n") | symbol();
76
+ dyn fn env::repr() = env() | filter(|[$k:$v] | !isFunction($v )) | map(|[$k:$v] | $k +" = "+repr($v )+"; // "+typeof($v )) | join("\n\n") | symbol();
77
+ dyn fn env::debug() = env() | map(|[$k:$v] | $k +" = "+_debug_nonfn($v )) | join("\n\n") | symbol();
79
78
fn _debug_nonfn($v) = if !isFunction($v) then debug($v) else $v;
80
79
81
-
82
80
dyn fn log::env($label) = log("variables:\n----\n" + env::pretty() + "\n----");
83
81
dyn fn log::debug_env($label) = log("variables:\n----\n" + env::debug() + "\n----");
84
82
0 commit comments