1 ! Copyright (C) 2020 Alexander Ilin.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: arrays assocs kernel make sequences ;
5 IN: rosetta-code.multisplit
7 : first-subseq ( seq separators -- n separator )
9 [ [ subseq-index ] dip 2array ] withd map-index sift-keys
10 [ drop f f ] [ [ first ] infimum-by first2 rot nth ] if-empty ;
12 : multisplit ( string separators -- seq )
14 [ dup _ first-subseq dup ] [
15 length -rot cut-slice [ , ] dip swap tail-slice