> Factor can tell you, try the following:
> \ sum see
>
> Which prints the following:
> USING: math ;
> IN: sequences
> : sum ( seq -- n ) 0 [ + ] binary-reduce ;
>

So the shortest solution is:

: sequence-sum ( seq -- sum ) sum ; inline

Which is pretty much pointless. If the 'sum' library word didn't exist then
you would write:

: sequence-sum ( seq -- sum ) 0 [ + ] reduce ;

But the Factor implementation actually uses binary-reduce instead of reduce,
which is an optimisation in case you're summing bignums (from what I can
tell from the binary-reduce documentation).
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to