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 --
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
>
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
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:
I think the reason it is parsed into a vector of start and end tags is
because it is much simpler when not all of the html data is available.
Or you are dealing with broken html code. There is no real XPath
support in any Factor vocab as far as I'm aware of. I once wrote a
half-completed binding
Hello again :)
I'm looking at implemented options of scraping web pages? I've hit into
this
http://re-factor.blogspot.nl/2014/04/scraping-re-factor.html
but that's a json output and I'm looking at pages that only have html. I
see there's parse-html and scrape-html to parse a url into a