Paste: some experiments
Author: | randy7 |
Mode: | factor |
Date: | Wed, 4 Feb 2009 18:19:55 |
Plain Text |
: overlap? ( array array -- ? )
2dup [ second ] [ first ] bi* >
[
[ first ] [ second ] bi* >= [ f ] [ t ] if
] [ 2drop f ] if ; inline
: spaces ( seq seq -- seq ? )
2dup [ overlap? ] curry map sift empty?
[ suffix t ] [ drop f ] if ;
: spaces2 ( seq seq -- seq )
2dup [ overlap? ] curry map sift empty?
[ suffix ] [ "overlap" write nl drop ] if ;
: non-overlaps ( seq -- seq )
{ } [ spaces2 ] reduce ;
: (overlaps?) ( seqs seq -- ? )
[ overlap? ] curry find 2array { f f } = not ;
: seq-overlaps? ( seq -- ? )
dup empty? [ drop f ] [
[ rest ] [ 1 head first ] bi
2dup (overlaps?) [ 2drop t ] [ drop seq-overlaps? ] if
] if ; recursive
{ { 1 2 } { 2 3 } { 5 8 } { 4 6 } { 10 12 } } 7000000 { 14 18 } <array> append
[ seq-overlaps? ] curry time
{ { 1 2 } { 2 3 } { 5 8 } { 4 6 } { 10 12 } }
[ seq-overlaps? ] curry time
Author: | LittleDan |
Mode: | factor |
Date: | Wed, 4 Feb 2009 18:44:01 |
Plain Text |
: overlaps? ( seq -- ? )
[ [ first ] compare ] sort
2 <clumps> [ first2 [ second ] [ first ] bi* < ] all? not ;
Author: | randy7 |
Mode: | factor |
Date: | Thu, 5 Feb 2009 23:06:48 |
Plain Text |
SYMBOL: vikky V{ } vikky set
: seq-overlaps? ( seq -- ? )
[ rest-slice ] [ 1 head first ] bi
[ vikky get ] dip 2dup (overlaps?)
[ 3drop t ] [
suffix
vikky set
seq-overlaps?
] if ;
Author: | randy7 |
Mode: | factor |
Date: | Thu, 5 Feb 2009 23:10:20 |
Plain Text |
( scratchpad ) { { 1 2 } { 2 3 } { 5 8 } { 4 6 } { 10 12 } } 7000000 { 14 18 } <array> append
[ seq-overlaps? . ] curry time
t
==== RUNNING TIME
0.0 seconds
New Annotation