Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...