Just shipped the first release of lo.zig - a utility library built around Zig’s idioms
Two main design decisions:
-
Zero hidden allocations. Functions that produce new data take an
Allocatorexplicitly. Everything else operates on slices and returns sub-slices or scalars - no surprises -
Lazy iterators.
map,filter,reject,withoutall return iterators. You can chain or call.collect(allocator)when you need a concrete slice
It covers slices (drop, take, first, last, zip, unzip, flatten, chunk, compact…), transforms (map, filter, reduce, forEach…), set operations (difference, intersection, union), search (find, indexOf, contains, every, some, none), map helpers (keysAlloc, valuesAlloc, entriesAlloc), strings (trimStart, trimEnd, startsWith, includes, replaceAll…), math (sum, mean, median, variance, stddev, lerp, remap), and type helpers (isNull, unwrapOr, coalesce, empty).
var it = lo.map(i32, i64, &.{ 1, 2, 3 }, double);
it.next(); // 2
lo.sum(i32, &.{ 1, 2, 3, 4 }); // 10
lo.variance(i32, &.{ 2, 4, 4, 4, 5, 5, 7, 9 }); // 4.0
lo.indexOf(i32, &.{ 10, 20, 30 }, 20); // 1
Install
zig fetch --save https://github.com/OrlovEvgeny/lo.zig/archive/refs/tags/v1.0.1.tar.gz
Feedback and PRs are welcome - I’m curious what functions people would want to see next