mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
944 B
944 B
dedup
Eliminating duplicate copies of repeating vectors.
Since: 2.3
Parameters
lt
: A list of vectors.eq
: A equality function. If it's ignored, use==
to compare elements. **Since: ** 3.0hash
: A hash function. If it's ignored, convert each element to a string and hash it. **Since: ** 3.0number_of_buckets
: The function uses a hash table internally. Change the number of buckets if you're trying to do optimization. **Since: ** 3.0
Examples
eq = function(e1, e2) e1[0] == e2[0] && e1[1] == e2[1] && e1[2] == e2[2];
points = [[1, 1, 2], [3, 4, 2], [7, 2, 2], [3, 4, 2], [1, 2, 3]];
assert(
dedup([[1, 1, 2], [3, 4, 2], [7, 2, 2], [3, 4, 2], [1, 2, 3]])
== [[1, 1, 2], [3, 4, 2], [7, 2, 2], [1, 2, 3]]
);
assert(
dedup([[1, 1, 2], [3, 4, 2], [7, 2, 2], [3, 4, 2], [1, 2, 3]], eq = eq)
== [[1, 1, 2], [3, 4, 2], [7, 2, 2], [1, 2, 3]]
);