【发布时间】:2015-06-29 23:17:26
【问题描述】:
对于提供的List 类型有一个indexedMap 函数:(http://package.elm-lang.org/packages/elm-lang/core/2.0.0/List#indexedMap)
indexedMap : (Int -> a -> b) -> List a -> List b
Same as map but the function is also applied to the index of each element (starting at zero).
indexedMap (,) ["Tom","Sue","Bob"] == [ (0,"Tom"), (1,"Sue"), (2,"Bob") ]
我创建了一个Grid 类型,其定义为type alias Grid a = List (List a)
我想为这个Grid 类型创建一个类似的indexedMap 函数,签名为indexedMap : ((Int, Int) -> a -> b) -> Grid a -> Grid b,但我知道该怎么做。
【问题讨论】:
标签: list function dictionary elm