Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

purescript - 如何在Purescript中使用mapWithIndex?(How to use mapWithIndex in Purescript?)

I'm a naive at Purescript, so I have a very basic issue while working with one of Purescript based frameworks.

(我对Purescript还是很幼稚,因此在使用基于Purescript的框架之一时遇到一个非常基本的问题。)

I'm using PrestoDOM and I wonder how to use mapWithIndex function from Data.Array package.

(我正在使用PrestoDOM ,我想知道如何使用Data.Array包中的mapWithIndex函数。)

I tried like the following,

(我尝试如下)

import Data.Array (mapWithIndex)
...
  (mapWithIndex
    ((item index) ->  // want to use both item and its index through loop
      textView [
        width MATCH_PARENT
        , height WRAP_CONTENT
        , text item
        , visibility index > 0 ? VISIBLE : GONE
      ]
    )
    data
  )
...

but I got this error:

(但是我得到了这个错误:)

Unable to parse module:
  unexpected [
  expecting indentation at column 1 or end of input

I know this error directly comes from my wrong use of mapWithIndex .

(我知道此错误直接源于我对mapWithIndex错误使用。)

  ask by tom carrier translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...