extra: use map-sum in a few places.

db4
John Benediktsson 2014-06-06 09:49:56 -07:00
parent ffed1387ab
commit 742ed3bc21
3 changed files with 4 additions and 4 deletions

View 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 ;

View 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

View 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=