Re: Strings and the like.

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

Lucius L. Hilley III wrote:

>  The error in using the below code is that it doesn't check to see if
there
>is a sequence inside s.  And if there is.  It fails to check it properly as
>well.
>
>Run this example:
>
>type whole_set(sequence s)
>  return find(0, s = floor(s))
>end type
>
>? whole_set({1, 2, 3})
>? whole_set({1, 2, {3}})
>? whole_set({1, 2, {3.14}})

Oops! Er... <SHEEPISH_MODE=ON>

>of course you could try this.
>
>type whole_set(sequence s)
>  return (compare(repeat(1, length(s)), s = floor(s)) = 1)
>end type

Okay, so then my all_true() function should be revised as follows:

function all_true(sequence s)
   return equal(s, repeat(1, length(s)))
end function

Thanks for the correction, Lucius! smile


Hep yadda,
Gabriel Boehme

----------
There is no mistake save one: the failure to learn from a mistake.

Robert Fripp
----------

</SHEEPISH_MODE>     (Well, I don't want to leave it on for *too* long...)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu