Ranges Do Not Work As Expected
zoltarTheGreat opened this issue Β· comments
While writing some emojicode I ran into some unexpected behaviors with ranges of steps not equal to 1.
π π
π y πβ© 0 5 2βοΈ π
π π‘ y βοΈβοΈ
π
π
This is a simple loop of printing the values in the range. I expected 3 digits. "0 2 4"
I only see displayed 2, "0 2"
I checked to see if this was only an interaction with loops but this code
π π‘ππβ© 0 5 2βοΈββοΈβοΈ
returns length 2, rather than the expected 3.
In other languages such as python the range function returns different results
>>> list(range(0, 5, 2))
[0, 2, 4]
Ive tried with other numbers and I also see similar issues. I am on the most recent version of emojicode.
It must be an off by 1 error somewhere but I have not gone into the source code to investigate it.
This is indeed a bug in π as the result of the division needs to be ceiled actually:
https://github.com/emojicode/emojicode/blob/master/s/β©.π#L51