Let's take it step-by-step. First, start defining a word (function) called group-by.

:group-by

Next, define it to take two arguments, a sequence (list or array) of values and a quotation (anonymous function or lambda) that computes a key for each element, and outputs an assoc (association, map, or dict). Names here are used only for documentation, it could take a foo and bar and return a baz.

(seqquot: (elt--key)--assoc)

The code inside the word is everything until the ";". We want to output a hashtable, so we first create one by cloning an empty hashtable (H{ }).

H{} clone

We will compose a word that duplicates each element to compute a key that is used to push each element into an appropriate bucket (a vector) in the hashtable. The push-at word has the signature ( value key assoc -- ). For example, if grouping by the length of a string, we want something that looks a bit like [ dup length H{ } push-at ]:

[ push-at ] curry compose [ dup ] prepose

We then, apply this quotation to each element in the sequence:

each

And, finally, we want to make sure that the hashtable that we created isn't "consumed", but kept on the stack as a return value.

The sequence>hashtable combinator outputs a hashtable after calling the quotation for each element of the sequence with the stack effect ( elt hashtable -- ). So you dip under the hashtable, dup the element and call your quotation to get a key, then push it onto a vector stored in the hashtable.