> Here's an incredibly rough work in progress
> https://gist.github.com/davespanton/034a0e9cfa540c0fa4d5
>
> Any comments welcome.
>

You can use ``2map-sum`` instead of ``2map sum`` which is faster because it
doesn't create an intermediate array.

If you're willing to venture into ``extras``, you can use
``sequences.extras`` to make ``find-left-index`` a little cleaner maybe:

    : find-left-index ( arr -- n )
        [ [ infimum ] supremum-by ] [ index ] bi ;

Similarly, you could get rid of ``right-of`` (since it isn't used) and make
``right-of-index``:

    : right-of-index ( n arr -- n n )
        [ [ nth ] with infimum-by ] [ dupd index ] bi ;

An alternative to ``arrange-strips`` could just be ``swap nths``

If I understand correctly, I think ``best-route`` could just be:

    : best-route ( arr -- arr )
        [ second ] infimum-by first ;

It seems it might be useful to make versions of ``supremum-by`` and
``infimum-by`` that return an element and its index.

I'd recommend using more descriptive stack names than ``arr`` :)

Best,
John.
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to