Re: length() and looping
- Posted by jessedavis Mar 13, 2017
- 1294 views
Thanks for your quick reply. I think the problem I have with this is that loop indices are by default atoms only, actually floating point only. Euphporia uses a slight of hand to deal with them. Implicit type conversions are not allowed in euphoria. for example:
integer i = 1.23is not allowed however,
for i = 1.23 + to_integer(23) to 77.3 dois allowed. Note the implicit conversion taking place. Most languages get around this problem by allowing one to declare the type of the index; but, not Euphoria (it MUST be an atom). An integer is a special case of an atom that the compiler often takes advantage of; but, apparently not in this case. However, Euphoria requires the type declaration for all other data types. As I am sure you realize, indices that can be integers are very useful. Attempting integer math using floating point numbers usually leads to a lot of annoying fuzz. With euphoria one has to fool around with an assortment of functions to convert the index to an integer after the fact.
for i = 1.999 + to_integer(1) to 30/3.0 by ceil(2.15) do integer j = to_integer(i) ? {i,j,round(i)} end for
None of this really matters. It is what it is. Sometimes I get caught!
Thanks again,
jd