-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add imap
to world DSL, with examples
#1990
Conversation
3f540a3
to
b84b4f9
Compare
b84b4f9
to
5a2376c
Compare
11291fc
to
fd44dc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I really like the clearing example. 🌲 🌲 🌲
|
||
data Op = Not | Neg | And | Or | Add | Sub | Mul | Div | Mod | Eq | Neq | Lt | Leq | Gt | Geq | If | Perlin | Reflect Axis | Rot Rot | Mask | Overlay | Abs | ||
data Op = Not | Neg | And | Or | Add | Sub | Mul | Div | Mod | Eq | Neq | Lt | Leq | Gt | Geq | If | Perlin | Mask | Overlay | Abs | IMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were there no worlds using reflection and rotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Reflection wasn't even fully implemented, as it turns out. And rotation is not very interesting until you have things like structures you can refer to from within the language.
Adds a new primitive
imap
, aka index map, primitive to the world DSL.imap
has typeWorld int -> World int -> World a -> World a
. Think of it like(Coords -> Coords) -> World a -> World a
, i.e. given a coordinate mapping, it creates a new world by looking up the cell at the transformed coordinates in the given base world. However, since there are no lambdas we cannot directly give it that type; instead, the firstWorld int
represents a functionCoords -> int
which gives an x coordinate, and the second gives the y coordinate. All told,imap wx wy wa
is like\c -> wa (wx c, wy c)
. For example,imap (-x) y w
is a reflection ofw
across the y-axis.Adds a description of
imap
to the language reference, as well as adding a few examples.Also removes the
rot
andreflect
primitives, since they can now be simply implemented in terms ofimap
.Depends on merging #1989 first. Closes #1584.