]> gitweb.factorcode.org Git - factor.git/commitdiff
extra: use map-sum in a few places.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 6 Jun 2014 16:49:56 +0000 (09:49 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 6 Jun 2014 17:14:11 +0000 (10:14 -0700)
extra/bank/bank.factor
extra/benchmark/chameneos-redux/chameneos-redux.factor
extra/benchmark/msgpack/msgpack.factor

index ec39554504432162562a46b51a0a54d55d46d868..c01b4d42978e7b6f19c11405f27fed007d6cb639 100644 (file)
@@ -15,7 +15,7 @@ C: <transaction> transaction
     over transactions>> push ;
 
 : total ( transactions -- balance )
-    0 [ amount>> + ] reduce ;
+    [ amount>> ] map-sum ;
 
 : balance>> ( account -- balance ) transactions>> total ;
 
index a1f9856e6495882cbfe59816e15f22f8e5305208..bcc0e85620dc6bf6a985b2015aa7ac75478a1b5b 100644 (file)
@@ -90,7 +90,7 @@ TUPLE: meeting-place count mailbox ;
         [ drop run-meeting-place ]
 
         [ nip [ [ count>> number>string write bl ] [ self-count>> number>text write nl ] bi ] each ]
-        [ nip 0 [ count>> + ] reduce bl number>chameneos-string print ]
+        [ nip [ count>> ] map-sum bl number>chameneos-string print ]
     } 2cleave ;
 
 ! 6000000 for shootout, too slow right now
index b0b82c9d6d983bfd5c78cb43dc34d6de213c302f..010839b4f11b33a70e52d7833355b10c0bcb01f1 100644 (file)
@@ -2,10 +2,10 @@ USING: kernel math math.constants msgpack sequences ;
 IN: benchmark.msgpack
 
 : pack-sum ( seq -- n )
-    0 [ >msgpack msgpack> + ] reduce ;
+    [ >msgpack msgpack> ] map-sum ;
 
 : pack-sum-lengths ( seq -- n )
-    0 [ >msgpack msgpack> length + ] reduce ;
+    [ >msgpack msgpack> length ] map-sum ;
 
 : msgpack-benchmark ( -- )
     500,000 iota pack-sum 124,999,750,000 assert=