USING: arrays assocs kernel io math math.parser prettyprint sequences splitting sorting ; IN: wp : inc-at ( key assoc -- ) [ 1 ] 2dip at+ ; inline : count-words ( string assoc -- assoc' ) [ " " split harvest ] dip '[ _ inc-at ] each ; : sort-assoc ( assoc -- seq ) >alist sort-values reverse ; : print-results ( seq -- ) [ number>string " " glue print ] assoc-each ; H{ } clone [ '[ _ count-words ] each-line ] [ sort-assoc print-results ] bi