RE: if statement not working
- Posted by Andy Serpa <renegade at earthling.net> Mar 21, 2002
- 448 views
bensler at mail.com wrote: > Andy Serpa wrote: > > <snip> > > > > s = {8,9,10} = {8,4,10} > > > > Now s is {1,0,1}. > > > > This facility is very useful, but can make if statements involving > > sequences a bit non-intuitive. Anyway, you gotta use equal & compare.. > > > > Could you give an example of how that might be useful? > I understand the concept, but I can't wrap my brain around how I could > use it. > I use it mainly in AI stuff where I need to work on binary strings in an explicit manner. I also use it a lot for stuff like this: x = {10,20,30,40,50,60} y = {30,10,25,40,60,65} z = (x < y)*x + (y <= x)*y z is now: {10,10,25,40,50,60} (taking the smaller element from each sequence -- the "=" is in the second half but not the first so equal elements will only be taken once) Yep, it's useful.