Paste: histogram and stuff

Author: erg
Mode: factor
Date: Fri, 12 Jun 2009 21:04:10
Plain Text |
: (sequence>assoc) ( seq quot assoc -- assoc )
    [ swap curry each ] keep ; inline

: sequence>assoc* ( assoc seq quot -- assoc )
    rot (sequence>assoc) ; inline

: sequence>assoc ( seq quot exemplar -- assoc )
    clone (sequence>assoc) ; inline

: sequence>hashtable ( seq quot exemplar -- hashtable )
    H{ } sequence>assoc ; inline

: histogram* ( assoc seq -- hashtable )
    [ inc-at ] sequence>assoc* ;

: histogram ( seq -- hashtable )
    [ inc-at ] sequence>hashtable ;

: collect-values* ( assoc seq -- hashtable )
    [ dupd push-at ] sequence>assoc* ;

: collect-values ( seq -- hashtable )
    [ dupd push-at ] sequence>hashtable ;


clear "asdfsadfasdf" collect-values "asasfasdfasdfasdfasdfasdfasdfasdfadsfsadfasdf" collect-values*

New Annotation

Summary:
Author:
Mode:
Body: