]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/bank/bank.factor
factor: trim using lists
[factor.git] / extra / bank / bank.factor
index a379a03828a227d7269b5befdda8e5ce050e4b22..fc214e05e31f3ecd8ddb46f68162f1295dba9e92 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors calendar kernel math math.order money sequences ;
+USING: accessors calendar kernel math math.order sequences ;
 IN: bank
 
 TUPLE: account name interest-rate interest-payment-day opening-date transactions unpaid-interest interest-last-paid ;
@@ -15,7 +15,7 @@ C: <transaction> transaction
     over transactions>> push ;
 
 : total ( transactions -- balance )
-    0 [ amount>> + ] reduce ;
+    [ amount>> ] map-sum ;
 
 : balance>> ( account -- balance ) transactions>> total ;
 
@@ -54,7 +54,7 @@ C: <transaction> transaction
 : process-day ( account date -- )
     2dup accumulate-interest ?pay-interest ;
 
-: each-day ( quot: ( -- ) start end -- )
+: each-day ( ... quot: ( ... day -- ... ) start end -- ... )
     2dup before? [
         [ dup [ over [ swap call ] dip ] dip 1 days time+ ] dip each-day
     ] [