What is the idiomatic way to merge two dicts?
If they are both hash, you can use hash-union
(or hash-union!
)
if they are both assoc list, I think you can just append them, provided that there’s no common element in both assoc lists.
I came up with those myself, but wouldn’t those be leaky abstractions? Is there some way of doing it at the dict abstraction without exploiting the actual representation?
Yes for leaky abstractions, but unfortunately, dict-union(!)
is not in the standard library. Feel free to submit a PR to add it.
Okay! So dict-union
would have to check what the representation is and make the appropriate union, yes?
yep
well, there are several possible designs.
One could be, disallow the operation if all dicts are not implemented in the same way (e.g., (dict-union (hash 1 2) (list (cons 3 4)))
is not allowed)
Another could be, if dicts are not implemented in the same way, the result will be implemented in the same way as the first argument. So:
(dict-union (hash 1 2) (list (cons 3 4)))
would evaluate to (hash 1 2 3 4)
, but (dict-union (list (cons 3 4)) (hash 1 2))
would evaluate to '([1 . 2] [3 . 4])
How can I load/store an image from/to a file?
Also, I’m interested in being able to get the bytes of the image.
In particular, use read-bitmap
to load from a file, and use the method save-file
to store to a file.
Nice, I guess there is one proc to get the data
I need that to use it in the FFI
Ive just seen the get-data-from-file
method. I think it is what I need. Thanks!
@jukkae has joined the channel