Paste: mostly-intersect
Author: | randy7 |
Mode: | factor |
Date: | Sun, 5 Apr 2009 14:55:38 |
Plain Text |
: has-all?
[ swap member? ] with map [ ] all? ;
: have-all
'[ _ has-all? ] filter ;
: most-is-n
length 2 /i 1+ ;
: most-items
[ concat ] [ most-is-n 1- ] bi
[ duplicates ] times prune ;
: mostly-intersect
dup most-items have-all ;
Author: | randy7 |
Mode: | factor |
Date: | Sun, 5 Apr 2009 15:52:07 |
Plain Text |
: count-item [ = ] curry count ;
: occurence
swap [ [ count-item ] with map ] with map ;
: occurs-enough?-map
occurence [ [ sum ] [ most-is-n ] bi >= ] map ;
: most-in-common
[ ] [ dup most-items occurs-enough?-map ] bi zip
[ dup second t = [ first ] [ drop f ] if ] map sift ;
New Annotation