Paste: { empty? harvest sift } for assocs

Author: kobi
Mode: factor
Date: Sat, 11 Sep 2010 18:03:17
Plain Text |
! suggestion: have empty?, harvest, sift as common words to all structures that make sense.

GENERIC: empty? ( item -- ? )    
M: sequence empty? 
    length 0 = ; inline
M: assoc empty?
    assoc-size 0 = ; inline

GENERIC: harvest ( seq -- newseq )
M: sequence harvest
    [ empty? not ] filter ;
M: assoc harvest
    [ nip empty? not ] assoc-filter ;
    
GENERIC: sift ( seq -- newseq )
M: sequence sift 
    [ ] filter ;
M: assoc sift    
    [ nip ] assoc-filter ;

New Annotation

Summary:
Author:
Mode:
Body: