mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Allow more expressions in the functional builtins.
This commit is contained in:
parent
3619153218
commit
46ba32f038
@ -143,4 +143,23 @@ assert {
|
||||
assert {
|
||||
ok = reduce((char_iter), [], "foo") == ["f", "o", "o"],
|
||||
desc = "We can use arbitrary expressions to refer to the macro.",
|
||||
};
|
||||
|
||||
let tpl_with_list = {
|
||||
list = [1, 2, 3],
|
||||
};
|
||||
|
||||
assert {
|
||||
ok = reduce(func(acc, s) => acc + [s + 1], [], tpl_with_list.list) == [2, 3, 4],
|
||||
desc = "We can use full expressions for any of the arguments to reduce",
|
||||
};
|
||||
|
||||
assert {
|
||||
ok = map(func(item) => item + 1, tpl_with_list.list) == [2, 3, 4],
|
||||
desc = "We can use full expressions for any of the arguments to map",
|
||||
};
|
||||
|
||||
assert {
|
||||
ok = filter(func(item) => item != 1, tpl_with_list.list) == [2, 3],
|
||||
desc = "We can use full expressions for any of the arguments to map",
|
||||
};
|
@ -577,9 +577,9 @@ make_fn!(
|
||||
_ => must!(punct!("(")),
|
||||
func => must!(expression),
|
||||
_ => must!(punct!(",")),
|
||||
acc => must!(trace_parse!(non_op_expression)),
|
||||
acc => must!(trace_parse!(expression)),
|
||||
_ => must!(punct!(",")),
|
||||
tgt => must!(trace_parse!(non_op_expression)),
|
||||
tgt => must!(trace_parse!(expression)),
|
||||
_ => must!(punct!(")")),
|
||||
(Expression::FuncOp(FuncOpDef::Reduce(ReduceOpDef{
|
||||
func: Box::new(func),
|
||||
@ -598,7 +598,7 @@ make_fn!(
|
||||
_ => must!(punct!("(")),
|
||||
func => must!(expression),
|
||||
_ => must!(punct!(",")),
|
||||
list => must!(trace_parse!(non_op_expression)),
|
||||
list => must!(trace_parse!(expression)),
|
||||
_ => must!(punct!(")")),
|
||||
(Expression::FuncOp(FuncOpDef::Map(MapFilterOpDef{
|
||||
func: Box::new(func),
|
||||
@ -616,7 +616,7 @@ make_fn!(
|
||||
_ => must!(punct!("(")),
|
||||
func => must!(expression),
|
||||
_ => must!(punct!(",")),
|
||||
list => must!(trace_parse!(non_op_expression)),
|
||||
list => must!(trace_parse!(expression)),
|
||||
_ => must!(punct!(")")),
|
||||
(Expression::FuncOp(FuncOpDef::Filter(MapFilterOpDef{
|
||||
func: Box::new(func),
|
||||
|
Loading…
x
Reference in New Issue
Block a user