mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
This is a breaking change for the map, filter, and reduce expressions but happily a forward compatible change for macros themselves.
34 lines
725 B
Plaintext
34 lines
725 B
Plaintext
|
|
// return a list of the fields in a tuple.
|
|
let fields = module{
|
|
tpl = NULL,
|
|
} => {
|
|
let reducer = macro(acc, field, value) => acc + [field];
|
|
|
|
let result = reduce reducer [], (mod.tpl);
|
|
};
|
|
|
|
// return a list of the values in a tuple.
|
|
let values = module{
|
|
tpl = NULL,
|
|
} => {
|
|
let reducer = macro(acc, field, value) => acc + [value];
|
|
|
|
let result = reduce reducer [], (mod.tpl);
|
|
};
|
|
|
|
let iter = module{
|
|
tpl = NULL,
|
|
} => {
|
|
let reducer = macro(acc, field, value) => acc + [[field, value]];
|
|
|
|
let result = reduce reducer [], (mod.tpl);
|
|
};
|
|
|
|
let strip_nulls = module{
|
|
tpl = NULL,
|
|
} => {
|
|
let filterer = macro(name, value) => value != NULL;
|
|
|
|
let result = filter filterer (mod.tpl);
|
|
}; |