Author: | Muzzleflash |
---|---|
Mode: | factor |
Date: | Fri, 20 Feb 2009 18:17:58 |
USING: kernel math sequences namespaces ; IN: search : every-index ( seq ch -- index-seq ) swap ! swap to ( ch seq ) SYMBOL: i 0 i set { } ! The current index [ 2over i get swap index-from dup ] ! Make n/f n/f ch i seq -- stack structure [ dup 1 + i set suffix ] ! if true; updates i and adds index to array [ drop 2nip ] ! if false ! When done: drop seq and ch, so index-seg remain while ;