Re: brain teaser
- Posted by "Hawke' (Mike Deland)" <mdeland at GEOCITIES.COM> May 11, 1999
- 407 views
<html> <font face=3D"arial" size=3D2>col22 wrote:<br> >Fill in the missing condition to make the code find if <br> >the angle "ang" is within the given range minang to maxang.<br> >minang =3D playera - veiwang / 2<br> >maxang =3D playera + veiwang / 2<br> >if xxxxx missing condition xxxxx then <br> =A0>=A0 blah<br> =A0>=A0 blah<br> >end if<br> <br> </font><font size=3D3>looks to me like you need the "range" function...<br> <br> <br> function range(atom testvalue, atom lower, atom upper)<br> return (lower<=3Dtestvalue) and (testvalue<=3Dupper)<br> end function<br> minang =3D playera - veiwang / 2<br> maxang =3D playera + veiwang / 2<br> if range(ang,minang,maxang) then <br> =A0 blah<br> =A0 blah<br> end if<br> <br> since you are using the function in an if..then, it cannot operate<br> (easily) upon sequences, however, it can be easily adapted to<br> work with sequences and objects (just change the declarations<br> from atom to object)<br> the conditional testing would change tho, as you would be<br> returning sequences of true/false values...<br> <br> HTH, take care--Hawke'<br> <br> </font></html>