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 sets module and maps:from_keys/2 #1226

Open
wants to merge 3 commits into
base: release-0.6
Choose a base branch
from

Conversation

bettio
Copy link
Collaborator

@bettio bettio commented Jul 6, 2024

Add sets module and required functions to make it work.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@bettio bettio marked this pull request as draft July 6, 2024 16:45
src/libAtomVM/nifs.c Outdated Show resolved Hide resolved
@bettio bettio force-pushed the add-sets-module branch 2 times, most recently from c0a145f to 162afd6 Compare July 10, 2024 22:58
@bettio bettio changed the base branch from main to release-0.6 July 11, 2024 11:54
@bettio bettio marked this pull request as ready for review July 11, 2024 11:54
CHANGELOG.md Show resolved Hide resolved
@bettio bettio force-pushed the add-sets-module branch 6 times, most recently from f90b827 to 6e2ae2d Compare July 13, 2024 22:23
Add missing free() in error condition, before raising out of memory error.

Signed-off-by: Davide Bettio <[email protected]>
This function is heavily used from modules such as sets.
So maps such as `#{1 => [], 2 => []}` can be quickly created from a list
of keys.

Signed-off-by: Davide Bettio <[email protected]>
Code has been taken from
github.com/erlang/otp/blob/master/lib/stdlib/src/sets.erl (main branch).

Few changes have been made to match documentation format, and to make
filter and map functions working with all erlang compiler versions we
support.

Tests for sets have been excluded on certain OTP versions since we use
maps:from_keys that is available since OTP 24.

Signed-off-by: Davide Bettio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants