Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符数组:
["AB", "CD", "EF", "GH"]
我只想回来["EF"]
["EF"]
如何输入字符串和数字并让它返回字符数组中该点的元素?
例如
showMe :: String -> Int -> String
您需要(!!), 索引运算符。
(!!)
["AB", "CD", "EF", "GH"] !! 2 == "EF"
[String] -> Int -> String但是在这种情况下正确的签名是(虽然(!!)更通用[a] -> Int -> a:)
[String] -> Int -> String
[a] -> Int -> a