6.4. Boost module for LINQ
The LINQ_BOOST module extends LINQ with pipe-friendly macros using underscore
syntax for inline predicates and selectors. Expressions like
arr |> _where(_ > 3) |> _select(_ * 2) provide concise functional pipelines.
See also LINQ for the full set of query operations. See LINQ — Language-Integrated Query for a hands-on tutorial.
All functions and symbols are in “linq_boost” module, use require to get access to it.
require daslib/linq_boost
Example:
require daslib/linq
require daslib/linq_boost
[export]
def main() {
var src <- [iterator for (x in range(10)); x]
var evens <- _where(src, _ % 2 == 0)
for (v in evens) {
print("{v} ")
}
print("\n")
}
// output:
// 0 2 4 6 8
6.4.1. Call macros
- _distinct_by
implements _distinct_by(iterator, expression) shorthand notation that expands into distinct_by(iterator, $(_) => expression).
- _none
implements _none(iterator, expression) shorthand notation that expands into none(iterator, $(_) => expression).
- _right_join
implements _right_join(srca, srcb, on, result) shorthand notation that expands into right_join(srca, srcb, keya, keyb, result).
- _select_many_2
Stage 2 of _select_many (see above). The collection selector’s parameter is now typed, so its body — and hence its element type — is inferred. Read that element type, inject it onto the result selector’s SECOND parameter, and expand into select_many_pair.
- _union_by_to_array
implements _union_by_to_array(iterator1, iterator2, expression) shorthand notation that expands into union_by_to_array(iterator1, iterator2, $(_) => expression).
- _min_max_average_by
implements _min_max_average_by(iterator, expression) shorthand notation that expands into min_max_average_by(iterator, $(_) => expression).
- _order_by_descending_to_array
implements _order_by_descending_to_array(iterator, expression) shorthand notation that expands into order_by_descending_to_array(iterator, $(_) => expression).
- _union_by
implements _union_by(iterator1, iterator2, expression) shorthand notation that expands into union_by(iterator1, iterator2, $(_) => expression).
- _group_join
implements _group_join(srca, srcb, on, result) shorthand — C# GroupJoin (outer).
- _left_join
implements _left_join(srca, srcb, on, result) shorthand notation that expands into left_join(srca, srcb, keya, keyb, result).
- _except_by
implements _except_by(iterator1, iterator2, expression) shorthand notation that expands into except_by(iterator1, iterator2, $(_) => expression).
- _group_by_lazy_to_array
implements _group_by_lazy_to_array(iterator, key) shorthand notation
that expands into group_by_lazy_to_array(iterator, $(_) => key).
Returns an array<tuple<key; array<elem>>> instead of an iterator.
- _order_by
implements _order_by(iterator, expression) shorthand notation that expands into order_by(iterator, $(_) => expression).
- _select_to_array
implements _select_to_array(iterator, expression) shorthand notation that expands into select_to_array(iterator, $(_) => expression).
- _where
implements _where(iterator, expression) shorthand notation that expands into where_(iterator, $(_) => expression).
- _distinct_by_to_array
implements _distinct_by_to_array(iterator, expression) shorthand notation that expands into distinct_by_to_array(iterator, $(_) => expression).
- _group_by_to_array
implements _group_by_to_array(iterator, key) shorthand notation that expands into group_by_lazy_to_array(iterator, $(_) => key).
- _cross_join
implements _cross_join(srca, srcb, result) shorthand notation that expands into cross_join(srca, srcb, result). 3-arg form with no on lambda — every (TA, TB) pair surfaces. Use _where after the cross to filter; that’s the explicit-shape inner join.
- _take_while
implements _take_while(iterator, expression) shorthand notation that expands into take_while(iterator, $(_) => expression).
- _max_by
implements _max_by(iterator, expression) shorthand notation that expands into max_by(iterator, $(_) => expression).
- _skip_while
implements _skip_while(iterator, expression) shorthand notation that expands into skip_while(iterator, $(_) => expression).
- _order_by_to_array
implements _order_by_to_array(iterator, expression) shorthand notation that expands into order_by_to_array(iterator, $(_) => expression).
- _unique_by_to_array
implements _unique_by_to_array(iterator, expression) shorthand notation that expands into unique_by_to_array(iterator, $(_) => expression).
- _intersect_by
implements _intersect_by(iterator1, iterator2, expression) shorthand notation that expands into intersect_by(iterator1, iterator2, $(_) => expression).
- _select_many
Stage 1 of the correlated SelectMany sugar — _select_many(src, $(o) => coll, $(o, x) => result).
- _select
implements _select(iterator, expression) shorthand notation that expands into select(iterator, $(_) => expression).
- _sequence_equal_by
implements _sequence_equal_by(iterator1, iterator2, expression) shorthand notation that expands into sequence_equal_by(iterator1, iterator2, $(_) => expression).
- _not_in
implements _not_in(element, subquery) shorthand notation that expands into !contains(subquery, element).
- _having
implements _having(iterator, expression) shorthand notation that expands into having_(iterator, $(_) => expression).
- _all
implements _all(iterator, expression) shorthand notation that expands into all(iterator, $(_) => expression).
- _min_max_by
implements _min_max_by(iterator, expression) shorthand notation that expands into min_max_by(iterator, $(_) => expression).
- _full_outer_join
implements _full_outer_join(srca, srcb, on, result) shorthand notation that expands into full_outer_join(srca, srcb, keya, keyb, result).
- _long_count
implements _long_count(iterator, expression) shorthand notation that expands into long_count(iterator, $(_) => expression).
- _min_by
implements _min_by(iterator, expression) shorthand notation that expands into min_by(iterator, $(_) => expression).
- _order_by_keys
implements _order_by_keys(iterator, $(x) => (k1, k2, …), descMask) — multi-key order with per-key direction. Expands into order_by_keys(iterator, key-lambda, descMask).
- _any
implements _any(iterator, expression) shorthand notation that expands into any(iterator, $(_) => expression).
- _in
implements _in(element, subquery) shorthand notation that expands into contains(subquery, element).
- _where_to_array
implements _where_to_array(iterator, expression) shorthand notation that expands into where_to_array(iterator, $(_) => expression).
- _having_to_array
implements _having_to_array(iterator, expression) shorthand notation that expands into having_to_array(iterator, $(_) => expression).
- _count
implements _count(iterator, expression) shorthand notation that expands into count(iterator, $(_) => expression).
- _join
implements _join(srca, srcb, on, result) shorthand notation that expands into join(srca, srcb, keya, keyb, result).
- _order_by_keys_to_array
implements _order_by_keys_to_array(iterator, $(x) => (k1, k2, …), descMask) shorthand notation that expands into order_by_keys_to_array(iterator, key-lambda, descMask).
- _group_by
implements _group_by(iterator, key) shorthand notation that expands into group_by_lazy(iterator, $(_) => key) — same backing function as _group_by_lazy. In-memory both names are aliases:
- _except_by_to_array
implements _except_by_to_array(iterator1, iterator2, expression) shorthand notation that expands into except_by_to_array(iterator1, iterator2, $(_) => expression).
- _unique_by
implements _unique_by(iterator, expression) shorthand notation that expands into unique_by(iterator, $(_) => expression).
- _group_by_lazy
implements _group_by_lazy(iterator, key) shorthand notation that expands into group_by_lazy(iterator, $(_) => key). Yields one tuple<key; array<elem>> per bucket — IGrouping shape, suitable for in-memory per-group processing (top-N per group, group-scoped filtering, grouped JSON emission). See spec history/dasSQLITE/API_REWORK.md "### 19-group_by".
- _order_by_descending
implements _order_by_descending(iterator, expression) shorthand notation that expands into order_by_descending(iterator, $(_) => expression).
- _intersect_by_to_array
implements _intersect_by_to_array(iterator1, iterator2, expression) shorthand notation that expands into intersect_by_to_array(iterator1, iterator2, $(_) => expression).