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

How to use actual arrays, 1D or 2D, with O(1) access and mutation complexity #14

Open
Martinsos opened this issue Jan 6, 2023 · 3 comments

Comments

@Martinsos
Copy link
Member

I still don't know how to work with arrays in Haskell that are fast like in other languages!
I would like to write a tutorial that explains this but for the beginners, and is as simple as possible, not assuming you know what ST monad is and similar, but instead shows with very good examples how to do it -> ideally I would just follow those examples and get it done.

I asked a bit around and was told that this probably has to do with ST monad, so maybe I should look in that direction.

I also found out there are Vector and Array libraries which can serve for this although the are somewhat different.

Some potential resources:

@Martinsos
Copy link
Member Author

Potential name of the blog post: "Beyond Lists".

@Martinsos
Copy link
Member Author

Vectors are intersting, since they have O(1) access. But mutation is still not O(1).
Certainly address them though.

@Martinsos
Copy link
Member Author

I read in a blog post:

💡 Haskell has mutable constructs (such as STArray and IORef), which you can use when you need mutability.

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

No branches or pull requests

1 participant