Re: converting sequence to string
- Posted by budmeister1 at JUNO.COM Mar 27, 2000
- 602 views
Here's a recursive routine that will "flatten out" a deeply nested sequences of atoms and sequences. global function flatten_seq( sequence s ) atom ec sequence ns ns = {} ec = 0 for i = 1 to length(s) do if atom(s[i]) then ns &= s[i] ec += 1 else ns &= flatten_seq(s[i]) end if end for if ec = length(s) then return {ns} else return ns end if end function Instead of simply taking a sequence and making it have all atoms inside, this will preserve "strings". For example: Input: {1,2,3,{4,5,{"hi",{"guy","girl"},6,'7'}},8,9,10} Output: {1,2,3,4,5,"hi","guy","girl",6,'7',8,9,10} The only downside is if the sequence has only atoms in it to begin with, then it will make them into a single string :) ----->Buddy budmeister1 at juno.com http://tenbux.iwarp.com/