Paste: Find field offsets in fixed text string
Author: | tgunr |
Mode: | factor |
Date: | Thu, 7 Mar 2013 19:14:10 |
Plain Text |
:: field-offsets ( str -- seq )
str first >vector :> rest!
f :> next!
f :> wlist! f :> olist!
f :> plist! f :> inword! 0 :> first!
0 :> pos! 0 :> count!
[ rest unclip next! rest!
next 32 =
[ inword
[ 32 wlist ?push wlist!
pos first + plist ?push plist! count 1- pos!
count 1- olist ?push olist!
1 first!
] when
f inword! ]
[ next wlist ?push wlist! t inword! ]
if
count 1+ count!
rest length 0= not
] loop
wlist >string " " split
pos first + plist ?push plist!
count first - olist ?push olist!
plist olist [ 2array ] { } 2map-as
H{ } zip-as
;
New Annotation