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

Array.indexedMap's index is 1023 maximum #271

Closed
evancz opened this Issue Jun 12, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@evancz
Member

evancz commented Jun 12, 2015

(Originally reported by @tyomalu in elm/elm-lang.org#262)

Here is the issue:

import Array
import Array (Array)
import Text (asText)

testArray: Array number
testArray = Array.initialize 3000 identity

mapArray: Array a -> Array a
mapArray array =
    Array.indexedMap (\i el -> 
        -- here max i == 1023
        case (Array.get i array) of
            Just x -> x
            otherwise -> el
    ) array


main =
    testArray |>
    mapArray |>
    asText

mapArray should just return array itself with values 0..2999, but it returns 0..1023, 0..1023, 0..951.
I've found that index in function passed to indexedMap reaches 1023 maximum.
I suggest the problem is in Array.js indexedMap_ function:

    function indexedMap_(f, a, from) {
      var newA = { ctor:"_Array", height:a.height, table:new Array(a.table) };
      if (a.height > 0) { newA.lengths = a.lengths; }
      for (var i = 0; i < a.table.length; i++) {
        newA.table[i] = a.height == 0 ? A2(f, from + i, a.table[i])
                                      : indexedMap_( f, a.table[i]
                                                   , i == 0 ? 0 : a.lengths[i - 1]); // should be i == 0 ? from : from + a.lengths[i-1]);?
      }
      return newA;
    }
@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Sep 8, 2015

Contributor

Closing this, since it appears it's fixed by https://github.com/elm-lang/core/pull/391. (Right, @eeue56?)

Contributor

jvoigtlaender commented Sep 8, 2015

Closing this, since it appears it's fixed by https://github.com/elm-lang/core/pull/391. (Right, @eeue56?)

@eeue56

This comment has been minimized.

Show comment
Hide comment
@eeue56

eeue56 Sep 8, 2015

Contributor

Yup, fixes it so can be closed

Contributor

eeue56 commented Sep 8, 2015

Yup, fixes it so can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment