问题描述
我怎么做[(char,int)] - >字符串复制不使用uncurry
例如在['a',9]中输入并且输出aaaaaaaaa
Haskell中的列表是类型齐次的:它们只能有一种类型。所以你永远不会有像`['a',9]这样的列表。
You can 有一个元组( '一个',9)
。你也可以有一个元组列表,例如 [('a',9)]
。但是,那么这个列表中的所有元组必须是(Char,Integer)
。
另请参阅:
但是,如果你不使用普通的旧的功能?
ghci的>复制9'a'
aaaaaaaaa
how can i do a [(char,int)] -> String with replicate not using uncurry
for example type in ['a',9] and it out puts "aaaaaaaaa"
Lists in Haskell are "type-homogeneous": they can only have one type in them. So you can't ever have a list like `['a',9].
You can have a tuple ('a',9)
. You can also have a list of tuples, such as [('a',9)]
. But then all tuples in that list must be of type (Char, Integer)
.
See also: http://en.wikibooks.org/wiki/Haskell/Lists_and_tuples
But what is your motivation for not using the plain old replicate
function?
ghci> replicate 9 'a'
"aaaaaaaaa"
这篇关于复制功能帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!