Commit Graph

67 Commits

Author SHA1 Message Date
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00
Adam Szaraniec 56ef3beaf8 feat: support for buffer iterator (#824)
* support for buffer iterator

* Code review fix

* fix: transforming the Buffer helper into a pull-based operator (it receives an iterator instead of channel)

* doc(it): adding loit.Buffer to doc

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-03-02 16:07:14 +01:00
Samuel Berthe 7f0c2e0297 feat: adding UnzipByErrX helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe af46a13bfc feat: adding RejectErr helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 6f42e74a11 doc: improve examples 2026-03-02 16:06:51 +01:00
Samuel Berthe ff0e293ce3 feat: adding FilterErr helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 4bb58fd2c6 feat: adding RepeatByErr helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 72a33aa397 feat: adding FilterKeysErr + FilterValuesErr helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe dd1d58e324 feat: adding FindDuplicatesByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 693e1ce3a8 feat: adding FilterMapToSliceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 7c55e5b6e3 feat: adding CrossJoinByErrX helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 8295993219 feat: adding FindErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe e94aa8d408 feat: adding ZipByErrX helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe fcc4f11fb5 💄 2026-03-02 16:06:51 +01:00
Samuel Berthe 4584a0b848 feat: adding LatestByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 2e0b3a19c9 feat: adding EarliestByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 32dce47128 feat: adding MinIndexByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe bef45080d4 feat: adding MaxIndexByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1db8f69a48 feat: adding KeyByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe fadc3aa9d5 feat: adding MaxByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1342d124d5 feat: adding PartitionByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1da649cc26 feat: adding WithoutByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 0950850fe2 feat: adding GroupByMapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe c9783b717b feat: adding MinByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 75474ff444 feat: adding GroupByErr+CountByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 153f867680 feat: adding MeanByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe b0b34ffc94 feat: adding UniqByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 788fb2997c feat: adding OmitByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe e9037c6e8c feat: adding ProductByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 2fac7c49dd feat: adding PickByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 361866b4d4 feat: adding ReduceRightErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 993b074a87 feat: adding MapToSliceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 20d76196f2 feat: adding ReduceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 12e2b4ceb4 feat: adding SumByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe f69cbe70f1 feat: adding MapEntiesErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 75d813d292 feat: adding FlatMapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe ec67399cd4 feat: adding MapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe b1263d4a41 feat: adding MapValuesErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe d4146ceb18 feat: adding MapKeysErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 14fff24f53 doc: fix simd doc 2026-02-28 16:11:07 +01:00
d-enk 68f827d9bf perf: optimize Substring to work directly with strings instead of converting to runes (#822)
* perf: optimize Substring to work directly with strings instead of converting to runes

- Rewrite Substring to iterate over string bytes directly, avoiding full []rune conversion
- Improve performance for long strings by only processing necessary portions
- Add comprehensive test cases for Unicode handling, invalid UTF-8, and edge cases
- Add BenchmarkSubstring to measure performance improvements
- Improve documentation with detailed parameter descriptions
- Handle invalid UTF-8 sequences by converting to []rune when needed

Bencstat:

                   │    old.txt    │               new.txt               │
                   │    sec/op     │    sec/op     vs base               │
Substring/{10_10}-4    558.85n ±  9%   39.75n ± 10%  -92.89% (p=0.000 n=8)
Substring/{50_50}-4    783.10n ±  6%   85.15n ±  5%  -89.13% (p=0.000 n=8)
Substring/{50_45}-4    773.30n ±  3%   126.5n ±  7%  -83.65% (p=0.000 n=8)
Substring/{-50_50}-4   794.00n ±  2%   177.6n ±  7%  -77.63% (p=0.000 n=8)
Substring/{-10_10}-4   542.85n ± 20%   41.82n ±  6%  -92.30% (p=0.000 n=8)
geomean               680.4n         79.52n        -88.31%

                   │  old.txt   │               new.txt                │
                   │    B/op    │   B/op    vs base                    │
Substring/{10_10}-4    432.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_50}-4    480.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_45}-4    464.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-50_50}-4   480.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-10_10}-4   432.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)

                   │  old.txt   │                new.txt                 │
                   │ allocs/op  │ allocs/op   vs base                    │
Substring/{10_10}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_50}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_45}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-50_50}-4   2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-10_10}-4   2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)

* Enhance substring documentation with Unicode details

Returns a substring starting at the given offset with the specified length. Supports negative offsets; out-of-bounds are clamped. Operates on Unicode runes (characters) and is optimized for zero allocations.

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-02-27 22:19:20 +01:00
Samuel Berthe ac8295b68a style(simd): rename sse to avx (#821)
* style(simd): rename sse to avx

* fix(exp,simd): apply the right avx512 constraints to a few methods

* fix(exp,simd): apply the right avx512 constraints to a few methods
2026-02-26 22:08:53 +01:00
Yuliya c1d11cb658 Add iterator slice helpers (#791)
* add iterator slice helpers and channel dedup/tee

* note unbounded memory growth in Distinct; simplify Take

* avoid extra iteration in Take/TakeWhile/TakeFilter and precompute Sliding step

* avoid reallocations in Sliding overlap shift

* sliding uses ring buffer

* refactor Sliding and expand TestSliding

* Remove Tee; add TakeFilter variant, rewrite Sliding

* remove channel Distinct/DistinctBy

* TakeFilter/TakeFilterI for slice

* Revert "TakeFilter/TakeFilterI for slice"

This reverts commit 6d2fcdc07b.

* doc  add new helpers to llms.txt

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-02-23 20:27:51 +01:00
Samuel Berthe 921fb61893 refactor: remove helpers deprecated for more than 3y 2026-02-22 05:20:42 +01:00
Varun Chawla 0b4623da1e fix: make Ellipsis operate on runes instead of bytes to prevent Unicode truncation (#796)
* fix: make Ellipsis operate on runes instead of bytes to prevent Unicode truncation

The Ellipsis function previously used byte-based length counting (len(str))
and byte-based slicing (str[:length-3]), which could split multi-byte
Unicode characters in the middle, producing garbled output.

This changes the function to use []rune conversion so the length parameter
counts Unicode code points instead of bytes. Emoji, CJK ideographs, and
other multi-byte characters are now never split in the middle.

Fixes #520

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: avoid rune slice allocation in Ellipsis

Use range-based iteration to count runes without allocating a []rune
slice, per reviewer suggestion. The early-return for length < 3 is
kept explicit for clarity.

* Simplify Ellipsis: remove early return for length < 3, reuse ellipsis const

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 19:29:10 +01:00
Samuel Berthe 035f1b358a Experiments: adding SIMD helpers (#801)
* feat(exp,simd): adding SumAxB helpers

* feat(exp,simd): adding MeanAxB and ClampAxB helpers

* feat(exp,simd): adding MinAxB and MaxAxB helpers

* refactor(exp,simd): group perf helper category + architecture

* feat(exp,simd): adding ContainsAxB helpers

* perf(exp,simd): cast to unsafe slice once

* feat(exp,simd): call the right SIMD helper based on local architecture

* chore: internal dependency linking

* Update exp/simd/math.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* style: fix linter

* style: fix linter

* chore: enable simd in makefile

* chore(ci): add simd package to test runs

* chore(ci): add simd package to test runs only for go 1.26

* fix(simd): fix overflow

* fix(simd): fix overflow and apply the same behavior than lo.Mean

* doc(exp,simd): adding initial doc

* refactor(simd): move intersect_avx2 and intersect_sse code into intersect_avx512

* fix(simd): call SSE fallback instead of lo.Sum for default helpers

* feat(simd): cache simd features on package init to avoid repeated checks

* perf(exp,simd): precompute length + improve code quality

* perf(exp,simd): faster iteration for min/max value

* test(exp,simd): adding benchmarks

* test(exp,simd): adding benchmarks results

* test(exp,simd): adding benchmarks results

* doc(exp,simd): adding warning for overflows in SIMD operations

* feat(exp,simd): adding more dispatch helpers

* feat(exp,simd): adding SumBy variants

* feat(exp,simd): adding MeanBy variants

* fix(exp,simd): faster clamp

* 💄

* doc(exp,simd): adding SumBy + MeanBy

* fix(exp,simd): faster SIMD operations

* chore(ci): enable the benchmarks temporary

* chore(ci): display cpu architecture before running tests

* chore(ci): github actions are hidding some useful stuffs

* chore(ci): no SIMD VM available at Github during the weekend ???

* test(exp,simd): larger epsilon

* oops

* perf(exp,simd): faster iterations

* doc(exp,simd): report last version of benchmarks

* 💄

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-21 19:19:36 +01:00
Samuel Berthe 94462b2521 doc: fix package name from "lo" to "it" (#794) 2026-02-08 02:26:36 +01:00
Samuel Berthe fedd0b6d2d doc: explain chunkstring inconsistency (#789)
* doc: explain chunkstring inconsistency

* doc: explain chunkstring inconsistency
2026-01-27 18:53:04 +01:00
RelicOfTesla 8590d84fcd Support Custom Assert (#755)
* custom Assert

* disable Test Parallel

* golangcli-lint warning fix

* Document custom handler for lo.Assert

Added a section on creating a custom handler for lo.Assert.

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-01-08 02:23:47 +01:00
Yuliya b6154d0f8d feat: add Take, TakeWhile, FilterTake, Window, and Sliding functions (#760)
* feat: add Take, TakeWhile, FilterTake, Window, and Sliding functions

Add five new slice manipulation functions with tests, examples, and documentation.

* improve Take function safety and add benchmarks

* rename FilterTake to TakeFilter and add README docs

* remove Window and Sliding benchmarks

* apply gofmt and fix linter errors

* apply gofmt and fix linter errors
2026-01-07 17:28:08 +01:00