Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I ensure amortized O(n) concatenation from Data.Vector?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. CO@hvr: No that is not what I want. I am pretty sure I am not doing it correctly in my question. However, I don't know the Data.Vector library that well and although the documentation `(++)` only states that it is *O(m+n)* worst case, it might still have *O(n)* amortized runtime.
      singulars
    2. COSo I hate it when people on StackOverflow answer questions with questions, but I'm about to do it :P - Why do you think you're doing it "wrong"? I assume you're using `State` for some reason unrelated to this question, so if you strip the `State`-related stuff away it's clear you're not doing anything crazy: <!-- language: lang-hs --> add :: Vector Int -> Vector Int -> Vector Int add v1 v2 = v1 ++ v2 - You noticed the docs say it runs in *O(n + m)* time; what led you to believe it should run faster?
      singulars
    3. COWrong might be too strong, I just wanted to say that I realize that add might end up being `O(n^2)* worst case. Also note that although something might run in *O(n+m)* worst case, it might run in *O(n)* amortized, the reason why I thought that could be achieved is that MVector can grow, (http://hackage.haskell.org/packages/archive/vector/0.9/doc/html/Data-Vector-Storable-Mutable.html#g:8), and the think I heard it somewhere. The reason I included State, and I know it is unclear, is that it is what I am doing in my application and it is not totally unrelated since I might store some other type.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload