Using fry is convenient. Due to how we bootstrap factor, we can't use fry right now in "core" vocabularies, like sequences, so you'll see a fair amount of curry and compose which are more or less what fry is doing, just not as clean syntax.
I love the REPL advent idea, go for it! And as you learn or hit roadblocks or have questions, please share. You can see how supremum-by is implemented by clicking on it in an expression, or doing ``see``. It uses ``after?`` instead of ``>``, which allows it to compare other kinds of objects with ``<=>`` when numbers are not passed in. Also, you might try using ``map-reduce`` which is a little faster than using ``unclip-slice`` and ``reduce``, (and using ``_ bi@`` instead of ``[ _ call ] bi@`` to simplify): : max-by ( seq quot -- result ) [ ] swap '[ [ _ bi@ > ] 2keep ? ] map-reduce ; inline Best, John. On Mon, Dec 10, 2018 at 6:46 AM Alexander Ilin <ajs...@yandex.ru> wrote: > Hey there! > > Sure, you can ask us here. I'm on sick leave, so got plenty of time. > Coincidentally, working on my Factor hobby project. > > What you're looking for is called supremum-by. > > Terminology is a bit uncommon. Look up supremum and infimum in the help > system. > > 10.12.2018, 17:06, "pet...@riseup.net" <pet...@riseup.net>: > > Hello fellow concatenative fans. > > > > I'm working my way through this year's advent of code[0]. I'm doing it > > in factor with a small twist - everything happening inside the REPL. > > Makes it more fun and challenging (for me), although I don't have any > > code to show for it in the end. > > > > I'm trying to find the right tools for the job since there's a lot of > > words already available. Sometimes I reinvent something before I find > > it, e.g. I wrote a last-n before finding last*. > > > > Would it be OK if I sometimes ask you for tips on what would be > > idiomatic/simpler/shorter/faster than what I have(n't) found? > > > > The first problem I really couldn't find is picking a maximum from a > > sequence based on a quotation pulling out the key. An example will say > > it the best I guess: > > > >> { { 1 2 } { 1 3 } { -1 4 } } [ second ] max-by . > > > > { -1 4 } > > > > Here is my definition: > > > > : max-by ( seq quot -- result ) [ unclip-slice ] dip '[ [ [ _ call ] bi@ > >> ] 2keep ? ] reduce ; inline > > > > Using fry for such a general word would be a bit of an overkill but for > > demonstration purposes it's OK I guess. > > > > Is there no standard word that already does something similar? Or is > > there a way to write this with the existing sequence combinators that > > it's so short there was no need to create this generic word? > > > > -- > > ------------ > > Peter Nagy > > ------------ > > > > _______________________________________________ > > Factor-talk mailing list > > Factor-talk@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/factor-talk > > ---=====--- > Александр > > > > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk >
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk