Skip to content

Commit

Permalink
doc: add documentation for groupBy.loop (leanprover#5349)
Browse files Browse the repository at this point in the history
We add some documentation explaining the auxiliary function in the
definition of `groupBy`. This has been moved here from Mathlib PR
[16818](leanprover-community/mathlib4#16818) by
request of @semorrison.

---------

Co-authored-by: Kim Morrison <kim@tqft.net>
  • Loading branch information
vihdzp and kim-em authored Sep 16, 2024
1 parent a745e33 commit 078e9b6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Init/Data/List/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,14 @@ such that adjacent elements are related by `R`.
| [] => []
| a::as => loop as a [] []
where
/--
The arguments of `groupBy.loop l ag g gs` represent the following:
- `l : List α` are the elements which we still need to group.
- `ag : α` is the previous element for which a comparison was performed.
- `g : List α` is the group currently being assembled, in **reverse order**.
- `gs : List (List α)` is all of the groups that have been completed, in **reverse order**.
-/
@[specialize] loop : List α → α → List α → List (List α) → List (List α)
| a::as, ag, g, gs => match R ag a with
| true => loop as a (ag::g) gs
Expand Down

0 comments on commit 078e9b6

Please sign in to comment.