Re: Comparing 2d sequences
- Posted by Jacques Deschenes <desja at QUEBECTEL.COM> Jun 11, 1997
- 768 views
At 20:38 97-06-10 -0300, you wrote: >---------------------- Information from the mail header ----------------------- >Sender: Euphoria Programming for MS-DOS <EUPHORIA at >MIAMIU.ACS.MUOHIO.EDU> >Poster: Ricardo Niederberger Cabral <rnc at INFOLINK.COM.BR> >Subject: Re: Comparing 2d sequences >------------------------------------------------------------------------------- > >> >How can I compare two 2d sequences dimensioned like this: >> >repeat(repeat(1,100),100) >> > (Each element ranging from 1 to 10, for example) >> >And create a 2d "mask" sequence with zeros where >> >the corresponding elements of the 2 sequences are different ? >> > I'm using the and_bits function but it sometimes (and don't know >> why) give >> >me something wrong. >> function Compare2D(sequence a, sequence b) >> return not (a-b) >> end function > > Thank you, but I want to know what is different between two 2D sequences >by reading a "mask" sequence (with the same length of the compared >sequences) where each 0 means that the corresponding element in both >compared sequences are different. > > >(Sorry if it's not clear, because I'm not a native english speaker) >--- >Ricardo Niederberger Cabral ><rnc at infolink.com.br> > If I understood What you meant, it's what it does. example: sequence a, b a = {{5,6,2,3,9},{5,2,6,4}} b = {{10,1,2,4,9},{5,2,8,4}} the above funtion applied to a,b will give: {{0,0,1,0,1},{1,1,0,1}} if you want that the mask preserve the identicals elements value you simply multiply the result by one of the compared sequence. function Compare2D(sequence a, sequence b) return (not (a-b))*a end function for the same value of a and b as above this function will return: {{0,0,2,0,9},{5,2,0,4}} If it's not what you want write the result of the function you want applied to the above a and b and post it here. Jacques Deschenes Baie-Comeau, Quebec Canada desja at quebectel.com