Comments (3)
Hi @hovox! Thanks for filing an issue. I've had some discussion about this with other people. The problem is that the chapter leaves the exact coordinate system unspecified. The coordinate system that you're using determines whether you should be adding or subtracting. I'll clarify this in the text in the next version of the chapter.
from functional-swift.
@wouter-swierstra I don't see how the coordinate system matters.
Picture a Region
of arbitrary size and position in an unlabelled coordinate system, with any number of random Position
s placed around it. By unlabelled, I mean we only know the positions of the Region
and Position
s relative to each other on a uniform grid.
Consider this the starting configuration.
Now picture the Region
moving one grid unit in any direction D
, and note how it's location relative to those of the Position
s changes.
Consider this the offset configuration.
Return to starting configuration.
Now recreate the offset configuration by moving the Position
s instead of the Region
(which is what the shift
function is supposed to do).
You have to move them in the opposite of direction D
to do so.
Both of shift
's parameters, offset
and region
are, by type definition, in the same coordinate system, therefore to effectively add an offset to a region, you need to subtract that offset from the positions it's testing.
from functional-swift.
@hovox OK. I misunderstood your original question.
You're right. I'm fixing this in our repository. It should be in the next version we push to our readers.
from functional-swift.
Related Issues (20)
- rename CollectionType.decompose into CollectionType.decomposed HOT 1
- Book revision in the book. HOT 2
- Wrong output in Theoretical Background: Currying HOT 1
- Ambiguous Issue HOT 1
- Swift 3 HOT 1
- About The book what name is Functional Swift first chapter HOT 2
- Syntax error in book
- Syntax error in book
- Syntax error In book
- Phrasing error in book
- Syntax error in book
- Syntax error in book
- Thinking Functionally - Example: the complicated canSafelyEngageShip(_:friendly:) function HOT 1
- generate function in Wrapping Core Image chapter crashes HOT 6
- Infinite loop in FileLinesIterator HOT 3
- error while calling colorGenerator HOT 5
- get error while call colorGenerator
- Hi,where is the playground? HOT 1
- Workaround for qsort intermediate let HOT 1
- Page 27: Sample code has `subtract` function, but text talks about `difference` function HOT 1
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 functional-swift.