escape-strings: Instead of [[ [=[ [==[, [[ [0[ [1[ ...
parent
c9684dbd14
commit
1cf3e1161d
|
@ -1,7 +1,8 @@
|
|||
! Copyright (C) 2017 John Benediktsson, Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: assocs assocs.extras combinators kernel math math.order
|
||||
math.statistics sequences sequences.extras sets ;
|
||||
USING: ascii assocs assocs.extras combinators kernel math
|
||||
math.order math.statistics sequences sequences.extras sets
|
||||
strings ;
|
||||
IN: escape-strings
|
||||
|
||||
: find-escapes ( str -- set )
|
||||
|
@ -14,6 +15,21 @@ IN: escape-strings
|
|||
} case
|
||||
] each 0 > [ over adjoin ] [ drop ] if ;
|
||||
|
||||
: find-number-escapes ( str -- set )
|
||||
[ HS{ } clone sbuf"" clone 0 ] dip
|
||||
[
|
||||
{
|
||||
{ [ dup char: \] = ] [
|
||||
drop 1 + dup 2 = [
|
||||
drop dup >string pick adjoin
|
||||
0 over set-length 1
|
||||
] when
|
||||
] }
|
||||
{ [ dup digit? ] [ [ dup 1 = ] dip '[ [ _ over push ] dip ] [ ] if ] }
|
||||
[ 2drop 0 over set-length 0 ]
|
||||
} cond
|
||||
] each 0 > [ >string over adjoin ] [ drop ] if ;
|
||||
|
||||
: lowest-missing ( set -- min )
|
||||
members dup [ = not ] find-index
|
||||
[ nip ] [ drop length ] if ;
|
||||
|
|
Loading…
Reference in New Issue