Output an element the number of times I want

前端 未结 6 1805
-上瘾入骨i
-上瘾入骨i 2021-01-21 03:11

I have this code:

lado ::  [([Char],Int)] -> [[Char]]
lado xs = [a | (a,b) <- xs]

I need to output this:

> lado [("A         


        
6条回答
  •  有刺的猬
    2021-01-21 03:21

    If you don't care about efficiency, you can make this work, I guess:

    lado xs =
      [ str
        | i <- [1..maxCount]
        , (str, j) <- xs
        , j >= i ]
      where
        maxCount = maximum (map snd xs)
    

提交回复
热议问题