test valid

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jean Hendrickx wrote:

>Hi,
>I wished to optimize a test that find a value in a sequence of valid
>numbers. I wondered that the third test was the fastest though it seems
>to be poor programming. Following the tests and results.
>Any advice or comment is welcome.
>Regards,
>--
>--TESTT.EX Comparison of speed:
>-- 3 tests to find a valid value JHendrickx 5/7/97

<------>code snipped<------->

I'm not sure what you are trying to do with your code.  The for value of
500000 seems a little much; it would be a lot easier to use this function=

I'm posting right now to check if a value is contained in a sequence.
----code starts here----

function check_value(atom tstval, sequence valid)
  if not find(tstval,valid) then
    return 0
  else
    return 1
  end if
end function

--usage--

atom t, v
sequence s

v =3D 6
s =3D {4,5,2,9,6,7}

t =3D check_value(v,s)
---code ends here---

t will be true since s contains the value 6.  Most of the time, you will
use this function to check user input and such against values already bui=
lt
into the program.  Hope this helps.

Regards,
  Bryan Watts

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu