如何返回Elm中的元素列表

时间:2016-04-19 16:10:47

标签: elm

我试图在ELM中构建一个简单数组的元素列表。预期结果实际上只是一个元素列表,其中1为第一项,2为第二项,依此类推。

compare()

但是我一直在第13行收到编译器错误。我尝试过将地图元素注释为html,但我不知道该怎么办。

import Html exposing (..)
import Html.Attributes exposing (class, id)
import List exposing (map)

theArray = [1,2,3,4,5,6]

createListItem item =
  li [] [ text (toString item)]

buildList collection =
  map createListItem collection

builtList = ul [] [(buildList theArray)]

main = 
  builtList

1 个答案:

答案 0 :(得分:7)

buildList已经返回List Html类型的值,因此您不需要(buildList theArray)左右的括号。将第13行更改为:

builtList = ul [] (buildList theArray)
相关问题