]> gitweb.factorcode.org Git - factor.git/commitdiff
project-euler.150: use cum-sum.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 03:55:43 +0000 (20:55 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 15 Jul 2015 03:55:43 +0000 (20:55 -0700)
extra/project-euler/150/150.factor

index 169e7005be155b28b65c54642c9098976eb6a81f..c31b2b3e2a4f7a3d065bcf2b530eb340400f0dbd 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Eric Mertens.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: hints kernel locals math math.order math.ranges project-euler.common
-    sequences sequences.private ;
+USING: kernel locals math math.order math.ranges math.statistics
+project-euler.common sequences sequences.private ;
 IN: project-euler.150
 
 ! http://projecteuler.net/index.php?section=problems&id=150
@@ -34,7 +34,7 @@ IN: project-euler.150
 ! sequence helper functions
 
 : partial-sums ( seq -- sums )
-    0 [ + ] accumulate swap suffix ; inline
+    cum-sum 0 prefix ; inline
 
 : partial-sum-infimum ( seq quot -- seq )
     [ 0 0 ] 2dip [ + [ min ] keep ] compose each drop ; inline