]> gitweb.factorcode.org Git - factor.git/commitdiff
Allow sigma and friends to use the stack
authorSamuel Tardieu <sam@rfc1149.net>
Sat, 27 Dec 2008 20:39:32 +0000 (21:39 +0100)
committerSamuel Tardieu <sam@rfc1149.net>
Sat, 27 Dec 2008 20:39:32 +0000 (21:39 +0100)
"sigma" used to use the stack to remember the current total.
This prevented the use of quotations manipulating elements
that were expecting to be on the stack.

This patch hides the counter while executing the quotation,
so that the latter can fully use the stack.

core/sequences/sequences.factor

index 31c7c8a4d73b2aa71e4df3f5bb5d22c2c19acafb..40a8892e8b2c19bc7241f3c9fbb9c9847cd4047b 100644 (file)
@@ -828,7 +828,7 @@ PRIVATE>
 
 : supremum ( seq -- n ) dup first [ max ] reduce ;
 
-: sigma ( seq quot -- n ) [ + ] compose 0 swap reduce ; inline
+: sigma ( seq quot -- n ) 0 -rot [ rot slip + ] curry each ; inline
 
 : count ( seq quot -- n ) [ 1 0 ? ] compose sigma ; inline