reduce-r (foldr for sequences)

db4
Sam Anklesaria 2009-05-04 18:38:29 -05:00
parent 0ca6a6c63f
commit e222378ecc
1 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel kernel.private slots.private math
USING: accessors kernel kernel.private locals slots.private math
math.private math.order ;
IN: sequences
@ -916,3 +916,10 @@ PRIVATE>
[ array-flip ] [ generic-flip ] if
] [ generic-flip ] if
] unless ;
:: reduce-r
( list identity quot: ( obj1 obj2 -- obj ) -- result )
list empty?
[ identity ]
[ list rest identity quot reduce-r list first quot call ] if ;
inline recursive