1. my brain block
		
		
Hey all, i can't seem to get by this one, and it's an old problem with the new
Eu
sequence twist.....
Given:
seqA = {"one","","three","","","six"}
seqB = {"1","2","","","5",""}
seqC = {"uno","dos","tres","","cinco",""}
How do i make a list of all the possible combinations, using recursion? It hasto
use
recursion, because i don't know the length of seqA or seqB or seqC. All the seqX
should be the same length, but with different contents,, and i don't know how
many
seqX there are,, could be 1 or could be 10 or could be 50. Matching against a
blank
subseq is not needed or good.
Results for 3 seqX needed:
"one","1","uno"
"one","1","dos"
"one","1","tres"
"one","1","cinco"
"three","1","uno"
"three","1","dos"
"three","1","tres"
"three","1","cinco"
etc,, all possible pairings, regardless of if they are the correct translation.
Kat,
befuddled,
and wondering now who Fud was....
		
	 
	
		
		2. Re: my brain block
		
		
That's what i did in my olde pascal days (daze?), but it also had the problem of
not
knowing how many (in pascal) substrings there were. I suppose i could just scale
it up
to some enormous nest of such, like you have for 3, but make an include with 500
of
them, i used 50 in the pascal code, but surely there is a faster and smaller way
to do
this.
Any idea on how much Eu can recurse?
Kat
On 9 Aug 2000, at 12:22, simulat wrote:
> Hi Kat
> This isn't recursive, but it would work with whatever goes into seqA, seqB
> and seqC.
>
> for a = 1 to length(seqA) do
>  for b = 1 to length(seqB) do
>   for = 1 to length(seqC) do
>    resultholder &= seqA[a] & seqB[b] & seqC[c]
>   end for
>  end for
> end for
>
> What's the structure for the seqA, seqB, etc?
> if it was something like SEQ=seqA & seqB & seqC & . . .
> Then you could modify the above to:
>
> for q = 1 to length(SEQ) do
>  for a = 1 to length(SEQ[1]) do
>   for b= 1 to length(SEQ[2]) do
>    for c= 1 to length(SEQ[3]) do
>     resultholder &= SEQ[1][a] & SEQ[2][b] & SEQ[3][c]
>    end for
>   end for
>  end for
> end for
>
> I can never get my head wrapped around recursion. The idea is simple - a
> function that calls itself until an escape condition is met - but I have a
> hard job applying it to actual cases.
>
> Bye
> Martin
>
> simulat at intergate.bc.ca
> http://www.intergate.bc.ca/personal/simulat/Index.html
>
>
> ----- Original Message -----
> From: Kat <gertie at PELL.NET>
> To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
> Sent: Wednesday, August 09, 2000 11:56 AM
> Subject: my brain block
>
>
> > Hey all, i can't seem to get by this one, and it's an old problem with the
> new Eu
> > sequence twist.....
> >
> > Given:
> > seqA = {"one","","three","","","six"}
> > seqB = {"1","2","","","5",""}
> > seqC = {"uno","dos","tres","","cinco",""}
> >
> > How do i make a list of all the possible combinations, using recursion? It
> hasto use
> > recursion, because i don't know the length of seqA or seqB or seqC. All
> the seqX
> > should be the same length, but with different contents,, and i don't know
> how many
> > seqX there are,, could be 1 or could be 10 or could be 50. Matching
> against a blank
> > subseq is not needed or good.
> >
> > Results for 3 seqX needed:
> > "one","1","uno"
> > "one","1","dos"
> > "one","1","tres"
> > "one","1","cinco"
> > "three","1","uno"
> > "three","1","dos"
> > "three","1","tres"
> > "three","1","cinco"
> >
> > etc,, all possible pairings, regardless of if they are the correct
> translation.
> >
> > Kat,
> > befuddled,
> > and wondering now who Fud was....
> >
>
>
		
	 
	
		
		3. Re: my brain block
		
		
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
--  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')
		
	 
	
		
		4. Re: my brain block
		
			- Posted by Kat <gertie at PELL.NET>
			Aug 09, 2000
 
			
						- 
				Last edited Aug 10, 2000			
 
					
		
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')
>
		
	 
	
		
		5. Re: my brain block
		
			- Posted by jiri babor <jbabor at PARADISE.NET.NZ>
			Aug 10, 2000
 
			
						- 
				Last edited Aug 11, 2000			
 
					
		
Kat wrote:
> Jiri, if i come back next lifetime, can i use your current brain?
You must be desperate. There are only retards left in this country.
Every body with half-a-brain left for Australia long time ago.
> 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?
Kat, in your original request you said: 'Matching against a blank
subseq is not needed or good.' I just followed your instructions.
Besides, it is cleaner this way, and it saves a bit of time as well as
memory too.
> 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?
Yep.
jiri