1. Split & Split_Match
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Sep 07, 1998
-
Last edited Sep 08, 1998
I had these laying around.
They are that usefull for real preproccesing.. but for converting a one
dimensional sequence (with end marks) to a 2-dimensional sequence is easily
done.
So, just in case anybody has a use for them:
-- Split & Split_Match by Ralf Nieuwenhuijsen (nieuwen at xs4all.nl)
-- Use NiceForm /d splits.e to get some documentation
-- By using this code or reading any furhter, you agree to the terms that
-- are available by email at a cost of 13034230493433 US. $
function split (object x, sequence s)
--/ Usage: s = split (delimiter, sequence)
--/ The sequence (second arg) will be divided in pieces by the delimiter
--/ The delimiter object is compared agains every element of the sequence
--/ All pieces are returned in one sequence
sequence ret
integer pos, prev
ret = {}
prev = 1
pos = find (x,s)
while pos do
ret = append(ret, s[prev..pos])
prev = pos + 1
pos = find(x, s[prev..length(s)])
end while
return append(ret, s[prev..length(s)])
end function
function split_match (object x, sequence s)
--/ Usage: s = split_match (delimiter, sequence)
--/ The sequence (second arg) will be divided in pieces by the delimiter
--/ The delimiter object is matched against any section of the sequence
--/ All pieces are returned in one sequence
sequence ret
integer pos, prev
ret = {}
prev = 1
if atom(x) then x = {x} end if
pos = match (x,s)
while pos do
ret = append(ret, s[prev..pos])
prev = pos + length(x)
pos = find(x, s[prev..length(s)])
end while
return append(ret, s[prev..length(s)])
end function
2. Re: Split & Split_Match
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
Sep 07, 1998
-
Last edited Sep 08, 1998
>They are that usefull for real preproccesing.. but for converting a one
They are *NOT* that usefull..
I seem to forget to put in the NOT occasionally..
Ralf