-
Notifications
You must be signed in to change notification settings - Fork 21
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
Help with preserving order in HashSet #51
Comments
yes for that we'd need a new data structure like LinkedHashSet or TreeSet. It is missing in prelude currently, that's true, and it would be a nice feature to have. Actually TreeSet enforces the same sorting order always, while LinkedHashSet keeps the one you give, so presumably LinkedHashSet would be the most interesting here. I'm not sure how much work would that be, presumably not that little :( |
No worries. Would use some sorting after using toArray() on a HashSet for now. You can focus on easy to implement features first. |
ah, I mean the library is actually relatively in maintenance mode at this point: it works great and the API works for me. but maybe such features can be added. i need to find some time for it. need to find out how linked hashmaps work, decide whether we'd roll our own, or reuse some library... |
okay. Initially when I was starting with prelude-ts, ran into some problems with folding over Vector/HashSet, remember it complaining about something where I believe it should not have. Javascript's reduce was a little more relaxed but still had some limitations. I will try to remember and report what it was here. One pattern that I use to write programs is to have an acumulator that is mutating as structure is being folded, the issue was something realted to that. |
Not sure if there are any Typescript libraries out there that provide 'if' and 'case/guard' expressions, since they are clearly preferable over 'if' and 'switch' statements provided by the javascript. I tried to come up with something and using below. My Typescript knowledge is limited and below functions when used as expressions suffers from types not being narrowed, but it would have been nice if these basic blocks could be provided out of the box.
X is recursive but did not find its recursive nature useful until now. |
no, I feel such basic control flow statements don't belong in prelude. We have combinators (like combining two options, things like that, a). but basic general-purpose control flow, i don't see it belonging in prelude. |
The HashSet is nice to get equality checks. But when you are using it to display UI elements, vector/array is preferable since order of elements seems to change on each re-render of the application. But vector doesn't have the nice properties of HashSet.
Is there some way to get a LinkedHashSet like functionality (Something like: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-linked-hash-set/)?
The text was updated successfully, but these errors were encountered: