Replies: 1 comment
-
|
Something along the lines of this idea could be nice. Here's a variation which would preserve the tuple structure and give more flexibility for the position of the modified value: NatMap.add(-> map, 1, "one");
NatMap.add(ref map, 1, "one");
NatMap.add(*map, 1, "one");A downside is that this might be hard to understand for beginners coming from other languages, but I like this general concept as a way to simplify using purely functional data structures. It's also worth mentioning that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Silly idea perhaps, but if we are serious about using the pure data structures to implement stateful ones, maybe, instead of providing wrapper classes holding a mutable cell, it would be enough to just add some sugar for updating a mutable location passed to a function call. Something like adding an _ <- _ operator (read "becomes"):
Sugar:
(perhaps with the restriction that exp0 is an lvar to avoid code duplication).
Probably a bad idea... (edited)
Beta Was this translation helpful? Give feedback.
All reactions