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