ucg/std/tuples.ucg

42 lines
853 B
Plaintext
Raw Normal View History

// return a list of the fields in a tuple.
let fields = module{
tpl = NULL,
} => {
let reducer = macro(acc, field, value) => {
result = acc + [field],
};
let result = reduce reducer.result [], (mod.tpl);
};
// return a list of the values in a tuple.
let values = module{
tpl = NULL,
} => {
let reducer = macro(acc, field, value) => {
result = acc + [value],
};
let result = reduce reducer.result [], (mod.tpl);
};
let iter = module{
tpl = NULL,
} => {
let reducer = macro(acc, field, value) => {
result = acc + [[field, value]],
};
let result = reduce reducer.result [], (mod.tpl);
};
let strip_nulls = module{
tpl = NULL,
} => {
let filterer = macro(name, value) => {
result = value != NULL,
};
let result = filter filterer.result (mod.tpl);
};