- Posted by Jacques Deschenes <desja at QUEBECTEL.COM> Jan 09, 1997
- 1798 views
--=====================_852879880==_ At 14:25 9-01-97 +0100, you wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: Marcel Kollenaar <M.Kollenaar at SLO.NL> >------------------------------------------------------------------------------- > >Hello Jacques, > >Did you already solve this problem with a self made function? > >> >> 2) multidimentionnal slicing, like >> >> let A be a 2 dimensions sequence >> sequence B >> >> B = A[2..4][3..6] >> > Hi marcel, I didn't but your question triggered it. See the attachement slice.ex demo It use recursive call, as the last dimension has to be the first one to be slice. --=====================_852879880==_ -- slicing multidimensionals sequence function slice(sequence s, sequence p) -- extract a slice from n dimensions sequence -- input: s sequence to slice -- p list of slices index in de form {{a1,a2},{b1,b2},...,{z1,z2}} sequence cut if length(p) = 1 then return s[p[1][1]..p[1][2]] end if cut = {} for i = p[1][1] to p[1][2] do cut = append(cut,slice(s[i],p[2..length(p)])) end for return cut end function -- slice() sequence a, b, c a = {1,2,3,4,5} b = {{1,2,3,10},{4,5,6,11},{7,8,9,12}} c = {b*2,b*3,b+23} puts(1,"a = ") ? a puts(1,"a[2..4] = ") ? slice(a,{{2,4}}) puts(1,"b = ") ? b puts(1,"b[2..3][2..4] = ") ? slice(b,{{2,3},{2,4}}) puts(1,"c = ") ? c puts(1,"c[1..2][2..3][1..1] = ") ? slice (c,{{1,2},{2,3},{1,1}}) --=====================_852879880==_ Jacques Deschenes Baie-Comeau, Quebec Canada desja at quebectel.com --=====================_852879880==_--