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

Immutable array based on RRB Vector #1286

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
453569c
force to remove wrong commit user
jialunzhang-psu Dec 26, 2024
e037236
Merge branch 'moonbitlang:main' into immutable-vec
jialunzhang-psu Dec 26, 2024
c6b5a25
sync
jialunzhang-psu Dec 26, 2024
127ec88
sync
jialunzhang-psu Dec 27, 2024
44e8a41
Merge branch 'moonbitlang:main' into immutable-vec
jialunzhang-psu Dec 27, 2024
846147c
sync
jialunzhang-psu Dec 27, 2024
1170529
add concat, waiting for tests
jialunzhang-psu Dec 28, 2024
276f14e
Merge branch 'main' into immutable-vec
jialunzhang-psu Dec 28, 2024
8fae296
add moon info
jialunzhang-psu Dec 28, 2024
7706d48
remove doc test for now
jialunzhang-psu Dec 28, 2024
7f733bb
add 1 simple test
jialunzhang-psu Dec 31, 2024
d753242
add more tests
jialunzhang-psu Dec 31, 2024
5b38a17
add random test
jialunzhang-psu Dec 31, 2024
bc5ce51
Merge branch 'main' into immutable-vec
jialunzhang-psu Dec 31, 2024
221d5b7
fix empty
jialunzhang-psu Dec 31, 2024
a54a083
doc
jialunzhang-psu Dec 31, 2024
4469988
Merge branch 'main' into immutable-vec
jialunzhang-psu Jan 1, 2025
4f9f0c0
add random test generator
jialunzhang-psu Jan 1, 2025
bf7951e
fix
jialunzhang-psu Jan 6, 2025
2d6285d
Merge branch 'main' into immutable-vec
jialunzhang-psu Jan 6, 2025
5b9f5c6
fix header
jialunzhang-psu Jan 6, 2025
ff02ea0
add README
jialunzhang-psu Jan 6, 2025
ad74d32
don't use inspect for array too long
jialunzhang-psu Jan 6, 2025
40d031c
coverage
jialunzhang-psu Jan 7, 2025
9b18671
coverage
jialunzhang-psu Jan 7, 2025
15c2b86
remove unused functions
jialunzhang-psu Jan 7, 2025
13625ee
Merge branch 'main' into immutable-vec
jialunzhang-psu Jan 7, 2025
9105c3a
comment
jialunzhang-psu Jan 7, 2025
10271ec
refactor test
jialunzhang-psu Jan 8, 2025
2534c7f
Merge branch 'main' into immutable-vec
jialunzhang-psu Jan 8, 2025
d5f5786
Merge branch 'main' into immutable-vec
jialunzhang-psu Jan 15, 2025
7806c04
add from_iter
jialunzhang-psu Jan 15, 2025
aa2c14e
fix
jialunzhang-psu Jan 15, 2025
f06aa74
header
jialunzhang-psu Jan 15, 2025
4046743
name clash
jialunzhang-psu Jan 15, 2025
7db85fd
name clash
jialunzhang-psu Jan 15, 2025
9cbac29
Merge branch 'main' into immutable-vec
Lampese Jan 17, 2025
6f97ff7
calling convention
jialunzhang-psu Jan 17, 2025
ca55910
add `op_add`
jialunzhang-psu Jan 17, 2025
abc8de9
moon info
jialunzhang-psu Jan 17, 2025
c6abd24
remove `copy`
jialunzhang-psu Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions immut/array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ println(arr1) // of([1, 2, 3, 4, 5])
println(arr2) // of([1, 2, 10, 4, 5, 6])
```

## Concatenation

You can use `concat()` to concatenate two arrays.

```moonbit
let arr1 = @immut/array.of([1, 2, 3])
let arr2 = @immut/array.of([4, 5, 6])
let arr3 = arr1.concat(arr2)
println(arr3) // of([1, 2, 3, 4, 5, 6])
```

## Query

You can use `op_get()` to get the value at the index, or `length()` to get the length of the array, or `is_empty()` to check whether the array is empty.
Expand All @@ -57,4 +68,9 @@ println(arr.each(fn(v) { println("element \{v}") }))
println(arr.eachi(fn(i, v) { println("index: \{i}, element: \{v}") }))
```

# TODO

- [] Add `split` and other operations that can be derived from `split` and `concat` like `insert` and `delete`.
- [] Add an algorithm description in README, since this algorithm does not use the invariant in the ICFP paper. Instead, it uses the "search step invariant" in Hypirion's thesis.
- [] Add a benchmark to compare the performance with the previous version.
- [] Optimizations such as tail.
Loading
Loading