Skip to content

Conversation

@contificate
Copy link
Contributor

Folding over a list to add its elements to a set (which is initially empty) is operationally equivalent to calling of_list (of the set), but potentially less efficient.

The implementation of of_list only uses add for small lists, e.g. the cases for lists [x_1; x_2; ...; x_N] for all N in range 2 <= N <= 5 are matched literally and expanded to:

add x_N (... (add x_1 (singleton x_0)))

However, larger lists are first sorted and the underlying tree representing the set is constructed directly.


This is a stray change I cherry-picked from another branch.

Folding over a list to add its elements to a set (which is initially empty) is
operationally equivalent to calling of_list (of the set), but
potentially less efficient.

The implementation of of_list only uses "add" for small lists, e.g. the
cases for lists [x_1; x_2; ...; x_N] for all N in range 2 <= N <= 5
are matched literally and expanded to:

   add x_N (... (add x_1 (singleton x_0)))

However, larger lists are first sorted and the underlying tree
representing the set is constructed directly.

Signed-off-by: Colin James <colin.barr@cloud.com>
@contificate contificate added this pull request to the merge queue Oct 11, 2024
Merged via the queue into xapi-project:master with commit f7c3e7f Oct 11, 2024
15 checks passed
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.

3 participants