Module ListBuilderOf
A module that declares predicates of2(...) to of8(...) for building a string from a list of
arguments of a custom type T, converted to strings via the toString predicate, using a
custom separator.
The toString predicate should be a unary predicate that takes an argument of type T and
returns a string. It should be declared with bindingset[result] and bindingset[arg], to have
two way binding between the input and output, allowing conversion and deconversion via one
predicate.
If you do not need to build strings from non-string arguments, you can simply use the module
ListBuilder<separator>. To build a type that extends string from a list of non-string
arguments, use TypedListBuilderOf<separator, T, S, toString>. You may also use the module
TypedListBuilder<separator, T> to build a type that extends string from a list of string-valued
arguments.
Example usage:
bindingset[result] bindingset[arg]
string toString(int arg) {
result = arg.toString() and
result.toInt() = arg
}
// selects "1,2"
select ListBuilder<Separator::comma/0, int, toString/1>::of2(1, 2)
Import path
import qtil.list.ListBuilderImports
| TypedListBuilderOf<ListBuilderOf::separator, string, ListBuilderOf::T, ListBuilderOf::toString> | A module that declares predicates |
Parameters
| separator | pred | |
| T | InfiniteType | |
| toString | bindInput |