Comments (8)
Let's use the name "update" after this has been actioned: #570
from stdlib.
OCaml's stdlib calls this update
OCaml's Base (stdlib replacement) calls this change
Haskell's containers calls this alter
Elixir's Map has get_and_update
OT: Reminds me of gleam-lang/gleam#1645
Maybe that idea could include an optional explanation why that alias exists, e.g. "similar to elixir get_and_update" or "reimplements ocaml update"
from stdlib.
#570 has the update
function becoming something like this:
dict.update return Result and Error if no key found
Which does make sense if the current update
is renamed to upsert
imo, given the sql naming of update/upsert. Whereas this function would need some other name.
from stdlib.
I have re-read your proposal and AFAIU it now, change works on dicts with keys that can exist or not exist and depending if they exist or do not exist they can handle those cases by injecting values or even removing values if a key existed all depending on the apply function of the change call? I hope I got it.
I think update does not communicate that, update does not communicate that something is removed. alter or change communicate that something could be removed. Now that we have upsert I am in favour of alter over change but that's just me.
from stdlib.
Closing this to track in the other issue. Thanks folks!
from stdlib.
@mooreryan is this the impl you meant? #659
from stdlib.
@mooreryan is this the impl you meant? #659
Looks like it, though I don't think that the function in that pull request should be called update
. The callback in that PR is also returning a Result
--that would not be my preference, however, I don't have a strong opinion about that aspect.
from stdlib.
I think the general policy is that we do not return Option.
I agree that it should be called change.
from stdlib.
Related Issues (20)
- Error in interator.find_map documentation
- Add `gleam/set.{map}`
- `float.parse` fails on exponential notation on JavaScript
- `bit_array.base64_encode` throws exception on large inputs
- Add `is_empty` to `set` and `dict` HOT 2
- `dynamic.element` does not work for lists on erlang HOT 5
- Issue with CRLF in string.contains() HOT 2
- [Dynamic] Ability to define input name and output name for dynamic values HOT 1
- 0.39 Regression: gleam/bit_array.{base64_encode} throws using OTP/25 HOT 1
- `parse_float` in JavaScript seems too strict HOT 4
- Add named capturing groups to gleam/regex.Match HOT 6
- `list.unique` needs quadratic time HOT 1
- Mismatch in `uri.percent_decode` example and behaviour HOT 1
- Add `regex.escape` HOT 2
- bit_array.compare (like int.compare) to compare BitArrays HOT 1
- Availability of `index_filter` HOT 1
- Function to take a number of random values from a list HOT 10
- Decode dynamic.optional_field different behaviour between 0.39.0 and 0.40.0 HOT 1
- Inaccurate documentation for `list.take` HOT 1
- Iterator try_fold will exceed call stack size in javascript target
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 stdlib.