Skip to content

Commit

Permalink
grouping.extras: group-by docs: note consecutive behavior and link co…
Browse files Browse the repository at this point in the history
…llect-by
  • Loading branch information
AndydeCleyre authored and mrjbq7 committed Apr 2, 2024
1 parent e848900 commit 962ac2a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion extra/grouping/extras/extras-docs.factor
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ IN: grouping.extras

HELP: group-by
{ $values { "seq" sequence } { "quot" { $quotation ( elt -- key ) } } { "groups" "a new assoc" } }
{ $description "Groups the elements by the key received by applying quot to each element in the sequence." }
{ $description "Groups consecutive elements by the key received by applying quot to each element in the sequence." }
{ $examples
{ $example
"USING: grouping.extras unicode.data prettyprint sequences strings ;"
"\"THis String Has CasE!\" [ category ] group-by [ last >string ] { } map-as ."
"{ \"TH\" \"is\" \" \" \"S\" \"tring\" \" \" \"H\" \"as\" \" \" \"C\" \"as\" \"E\" \"!\" }"
}
{ $example
"USING: grouping.extras prettyprint sequences strings ;"
"{ \"apple\" \"anchovy\" \"banana\" \"anise\" \"bagel\" \"bratwurst\" } [ first 1string ] group-by ."
"V{\n { \"a\" V{ \"apple\" \"anchovy\" } }\n { \"b\" V{ \"banana\" } }\n { \"a\" V{ \"anise\" } }\n { \"b\" V{ \"bagel\" \"bratwurst\" } }\n}"
}
} ;

{ group-by collect-by } related-words

HELP: <n-groups>
{ $values
{ "seq" sequence } { "n" integer }
Expand Down

0 comments on commit 962ac2a

Please sign in to comment.