Hi Dan,

I liked your recent blog post.

Two typos:

- in the stack based definition of split-reduce, the final * should be call
- some combinators are missing inline declarations

Continuing our IRC discussion, here is the fastest version of 
split-reduce I could come up with:

: split-reduce ( seq start quot -- value )
    pick length {
        { 0 [ drop nip ] }
        { 1 [ 2drop first ] }
        { 2 [ >r drop first2 r> call ] }
        { 3 [ >r drop first3 r> 2apply ] }
        [ drop >r >r halves r> r> [ [ split-reduce ] 2curry 2apply ] 
keep call ]
    } case ; inline

It's several times faster than a linear reduce for computing the 
factorial of 40,000.

I've put this into sequences and changed sum and product to use it.

Slava


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to