Paste: tinkering

Author: randy7
Mode: factor
Date: Mon, 5 Jan 2009 10:16:49
Plain Text |
! the idea is to find repeating code in factor
! just experimenting from the listener - using probably needs more.

USING: io.encodings.utf8 fry grouping sets ;

: count-seq ( seq -- seq' ) dup '[ _ swap '[ _ = ] count ] map ;
: count-dups ( seq -- seq ) dup count-seq zip prune >array ;
: just-2+ ( seq -- seq ) [ dup second  2 < [ drop f ] when  ] map harvest ;



"resource:basis/alarms/alarms.factor" utf8 file-contents
! TODO: should actually scan the entire factor dirs into one string. sorry i'm still learning :D

! TODO: remove \n \r and all double-spaces..
" " split

[ length >array 20 head [ 1+ ] map  ] keep
'[ _ swap clump [ " " join ] map ] map

count-dups just-2+
[ [ second ] bi@ <=> ] sort reverse

Annotation: major bug, just found out today

Author: randy7
Mode: factor
Date: Sat, 17 Jan 2009 23:15:16
Plain Text |
"resource:basis/alarms/alarms.factor" utf8 file-contents


 "[\n|\r|\t|\s\s]" <regexp> " " re-replace


[ length >array 20 head [ 1+ ] map  ] keep
[ swap clump ] curry map
! ... 

count-dups just-2+
[ [ second ] bi@ <=> ] sort reverse

Annotation: I think it works now

Author: randy7
Mode: factor
Date: Sat, 17 Jan 2009 23:43:42
Plain Text |
all-source-files [ utf8 file-contents ] map " " join

 "[\n|\r|\t|\s\s]" <regexp> " " re-replace


[ length >array 20 head [ 1+ ] map  ] keep
" " split harvest
[ swap clump ] curry map
[ [ " " join ] map ] map
count-dups just-2+
[ [ second ] bi@ <=> ] sort reverse

New Annotation

Summary:
Author:
Mode:
Body: