Comments (3)
wip
- Code compiles. Existing tests pass.
- Need to write new tests for line::Iterator::next(). He also needs to be refactored into more functions?
- Merge #84 into this issue?
- Code is rough around the edges in general. Needs a second pass. It's too late to keep working tonight, though.
What I did:
- Remove Predicate trait. It turns out that you can use the existing iterator API without providing boxed closures.
- Change line::generic() into line::Iterator. He still infinitely iterates unless you filter him, but now I'm not the one handling enumeration, predicate application, etc. Stdlib does that.
- Make denumerate() function to reverse the effect of Iterator::enumerate()
- Alter Walls and Range predicates to be used with Iterator::scan().
- Range now returns None if index is greater than range. Previously, it was greater-or-equal. This boolean condition changed because the finer points of the logic changed when I converted from a loop to an iterator.
from hex_math.
Now that I've got this iterator stuff implemented, I should look at making other iterators.
Maybe Range/flood could use the same iterator with different predicates. Not sure.
Rotate and travel could maybe be iterators. They'd probably be a lot easier to write, but it also doesn't make as much sense. I mean.. maybe. Maybe you could provide arbitrary predicates to travel. Travel until you run out of move points maybe? Idk. Don't implement those yet. If I find a good use case, then do it. Otherwise it's just added complexity. Travel is already a very simple function, and it doesn't seem like he needs predicates.
Line of sight? I guess he could be an iterator. You could take from the iterator until you run out of vision distance or something? But... wouldn't you /always/ want to see as far as you can? There's no circumstance in which you would maybe want to break that loop /before/ you've seen everything that you can... Is there?
from hex_math.
Merged
from hex_math.
Related Issues (20)
- Make Point/etc a tuple struct, eliminate new() HOT 2
- Improve on HasValues, generics, etc.
- Make a CubePoint instead of Point::s()
- Consider making some newtype structs HOT 2
- Refactor the generic line() function HOT 2
- Combine range() and flood() HOT 9
- Maybe extract Predicate trait into a library HOT 2
- Convert denumerate() function into an iterator adapter
- Generic Point<T> instead of FloatPoint/etc HOT 1
- Implement Point functionality in a trait HOT 4
- Forgot to remove Predicate trait
- Travel should have specialized functions HOT 2
- Implement functions using Into instead of Borrow HOT 2
- Make a Vector(i32, i32, i32) newtype HOT 2
- Refactor base_ring implementation HOT 1
- Move line iterator, denumerate() out of traits::line HOT 1
- Separate line/ray into separate packages
- point.direction(other) instead of Direction::from((point, other))
- Make a prelude
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hex_math.