"hi":"there" :12:6: Couldn't match expected t-6ren">
gpt4 book ai didi

haskell -++ 和 : in haskell? 有什么区别

转载 作者:行者123 更新时间:2023-12-02 02:49:59 25 4
gpt4 key购买 nike

我不明白这个——

Prelude> "hi"++"there"
"hithere"
Prelude> "hi":"there"

<interactive>:12:6:
Couldn't match expected type `[Char]' with actual type `Char'
Expected type: [[Char]]
Actual type: [Char]
In the second argument of `(:)', namely `"there"'
In the expression: "hi" : "there"
Prelude>

为什么那不也返回“到那里”?

最佳答案

类型。在 GCHi 中试试这个:

Prelude> :t (:)
(:) :: a -> [a] -> [a]
Prelude. :t (++)
(++) :: [a] -> [a] -> [a]

关于haskell -++ 和 : in haskell? 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11569650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com