Tangled Game v1.0.0

Thanks for the rationale.

As far as the ranged loop, I would expect a loop to iterate over the range specified, not the range minus one from the end. This seems intuitive to me.

is there a way to determine the minimum number of moves necessary? it would be nice to compare how one does

Possibly. Feel free to submit a pull request.

1 Like

It catches me offguard too. For what it’s worth they have an inclusive range syntax as well:

for Index in 1..=5 
{
  do_something();
}

When I looked it up, the rationale given was because it was a 0 based indexing so most loops were of the form 0 to (length - 1), so they made the default range type non inclusive on the upper bound to make that simpler. It also mimic’ed the traditional for loop structure ( for(i=0; i<length; i++) => for i in 0 .. Length )

It’s a little loose for my taste, but I understand their thought process.

EDIT: This had some (old) discussion on it: `...` vs `..=` for inclusive ranges - #3 by japaric - ideas (deprecated) - Rust Internals

Wow. Looking at that very first sentence:

We’ve currently adopted .. as syntax for exclusive ranges and ... as the syntax for inclusive ranges.

:scream:

So glad I didn’t have to use Rust in 2015.

I know about the ..= syntax but in general we avoid indexing where I work. We can almost always avoid it by using functional iteration instead.

Nim and Kotlin have a syntax I like a bit better: .. means the same as in Ada, and ..< means a range that doesn’t include the last element.

He also writes,

It is my opinion that inclusive rangers are a relatively rare thing.

Wow. Not in my experience… Not with Ada anyway. And it always trips me up in every language that insists on 0-based indexing.

1 Like

That’s because he’s most likely ONLY ever used c based languages.

1 Like