The *.extras vocabularies are places to incubate new words. We haven't done the
best job of documenting them and promoting to the core/basis vocabularies.
> On Nov 18, 2016, at 8:21 AM, Alexander Ilin wrote:
>
> Hello, Björn!
>
> 18.11.2016, 18:25, "Björn Lindqvist"
Hello, Björn!
18.11.2016, 18:25, "Björn Lindqvist" :
> USE: sequences.extras
> [ id>> ] sort-with [ id>> ] group-by [ second first ] map
I could not find `group-by` using the Browser. Grepping the source tree, it
turned up in `grouping.extras`.
> USE:
John, thank you very much! : )Really helpful stuff! 18.11.2016, 18:13, "John Benediktsson" :P.S., Hah I should have called it unique-by, it's too early in the morning! P.P.S., I committed this word into sets.extras, with one small change besides the name which is to size the
2016-11-18 15:36 GMT+01:00 Alexander Ilin :
> Hello, all!
>
> I have an interesting little task for you today.
>
> Let's say you have a sequence of tuples, and you want to remove all tuples
> with duplicate ids, so that in the new sequence there is only one tuple with
>
Maybe something like this:
: duplicates-by ( seq quot: ( elt -- key ) -- seq' )
HS{ } clone '[ @ _ ?adjoin ] filter ; inline
Then you can use it:
IN: scratchpad { 1 2 3 4 5 } [ 2/ ] duplicates-by
{ 1 2 4 }
IN: scratchpad sequence-of-tuples [ hash>> ] duplicates-by
It would
Hello, all!
I have an interesting little task for you today.
Let's say you have a sequence of tuples, and you want to remove all tuples
with duplicate ids, so that in the new sequence there is only one tuple with
each id.
Here's my solution:
TYPED: dedupe-by-hash ( seq: sequence --