How to convert a list of (Char,Int) to a string with the given number of repeated chars?

前端 未结 4 1679
予麋鹿
予麋鹿 2020-12-22 05:23

How can I convert [(char,Int)] to a String of the Int in the second component gives the number of repetitions of the character in the first component? For examp

4条回答
  •  无人及你
    2020-12-22 06:01

    Hugs> map (\(c,n) -> replicate n c) [('a',9), ('b',10)]
    ["aaaaaaaaa","bbbbbbbbbb"]
    

    or

    map (uncurry $ flip replicate)
    

提交回复
热议问题