Skip to content
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

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Add imap to world DSL, with examples #1990

merged 4 commits into from
Jun 26, 2024

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Jun 25, 2024

Adds a new primitive imap, aka index map, primitive to the world DSL. imap has type World 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 first World int represents a function Coords -> 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 of w across the y-axis.

Adds a description of imap to the language reference, as well as adding a few examples.

Also removes the rot and reflect primitives, since they can now be simply implemented in terms of imap.

Depends on merging #1989 first. Closes #1584.

@byorgey byorgey force-pushed the imap branch 2 times, most recently from 11291fc to fd44dc1 Compare June 25, 2024 22:42
Copy link
Member

@xsebek xsebek left a 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. 🌲 🌲 🌲

Comment on lines 74 to +75

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
Copy link
Member

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?

Copy link
Member Author

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.

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Jun 26, 2024
@mergify mergify bot merged commit 1735416 into main Jun 26, 2024
14 checks passed
@mergify mergify bot deleted the imap branch June 26, 2024 20:09
@byorgey byorgey added the CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement more world manipulation functions in world DSL
2 participants