1. double slicing possible?
- Posted by CHARN1407 at AOL.COM Jan 12, 2000
- 328 views
- Last edited Jan 13, 2000
I was wondering if it was possible to slice two dimensions of a sequence in a single statement. Example: --begin code include file.e procedure testprint(sequence text) for i=1 to length(text) do puts(1,text[i]) end for end procedure sequence text1 text1 = { "Hi there", "Are you ", "New to E", "uphoria?" } procedure Main() testprint(text1[1..3][3..7]) --the interpreter seems to end the statement after the end procedure --[1..3] in this line and it stops --end code Is there any way to do this in a single statement? TIA, CHARN
2. Re: double slicing possible?
- Posted by Jeffrey Fielding <JJProg at CYBERBURY.NET> Jan 12, 2000
- 314 views
- Last edited Jan 13, 2000
I don't think there is any way to do it with built-in commands, but you could write a function: function multiSlice(sequence s, sequence slices) sequence t integer l l = length(slices) s = s[slices[1][1]..slices[1][2]] if l > 1 then t = slices[2..l] for i = 1 to length(s) do s[i] = multiSlice(s[i],t) end for end if return s end function Jeffrey Fielding JJProg at cyberbury.net http://members.tripod.com/~JJProg/ CHARN1407 at AOL.COM wrote: > I was wondering if it was possible to slice two dimensions of a sequence in a > single statement. Example: > > --begin code > include file.e > > procedure testprint(sequence text) > for i=1 to length(text) do > puts(1,text[i]) > end for > end procedure > > sequence text1 > text1 = { > "Hi there", > "Are you ", > "New to E", > "uphoria?" > } > > procedure Main() > testprint(text1[1..3][3..7]) --the interpreter seems to end the > statement after the > end procedure --[1..3] in this line and it stops > --end code > Is there any way to do this in a single statement? > > TIA, > CHARN