Re: my brain block
On 10 Aug 2000, at 13:44, Jiri Babor wrote:
> Kat,
>
> Have a look at the routine below. Is it what you wanted?
> You will need Gabriel's pretty print include for a prettier output.
>
> jiri
Umm, a few questions:
1) Jiri, if i come back next lifetime, can i use your current brain?
2) You have the strip function, which i understand, but is there a reason why
you didn't
mesh the seqs first, then strip each one? (i assume you'll say speed and memory
requirements.) Or do the mesh, and if a "" was found in the mesh operation,
abort it? (I
figure here you'll say complexity.)
3) Where you have
print(1, mesh({sa,sb,sc}))
i have no idea how many sequences i'll have from one run to the next, but since
the
mesh() accepts everything passed as one nested sequence, i assume if i build
such a
nested seq and pass it in the same form, it will still work as designed? Like:
-- count the seqs
for loop = 1 to length(something) do
-- concat them together
tempmesh &= seq
end for
-- now process them
mesh({tempmesh})
Kat,
curious as a
> -- kat.ex
> -- jiri babor
> -- jiri_babor at hotmail.com
> -- 00-08-10
>
> include print.e -- Gabriel's extension
>
> function strip(sequence s)
> -- return sequence s with empty substrings removed
> sequence v,si
>
> v = {}
> for i=1 to length(s) do
> si = s[i]
> if length(si) then
> v = append(v, si)
> end if
> end for
> return v
> end function
>
> function mesh(sequence s)
> sequence u,v
> integer n
>
> n = length(s)
> for i=1 to n do
> s[i] = strip(s[i])
> end for
>
> v = {}
> for i=1 to length(s[1]) do
> v = append(v, {s[1][i]})
> end for
> for i=2 to n do
> u = v
> v = {}
> for j=1 to length(u) do
> for k=1 to length(s[i]) do
> v = append(v, append(u[j], s[i][k]))
> end for
> end for
> end for
> return v
> end function
>
> -- test --------------------------------------------------------------
>
> constant sa = {"one","","three","","","six"}
> constant sb = {"1","2","","","5",""}
> constant sc = {"uno","dos","tres","cinco",""}
>
> print(1, mesh({sa,sb}))
> puts(1, "\n\n")
> print(1, mesh({sa,sb,sc}))
> puts(1, '\n')
>
|
Not Categorized, Please Help
|
|