String formatting in Haskell

前端 未结 5 599
一生所求
一生所求 2021-02-05 00:05

What is Haskell\'s equivalent of

string str = string.Format(\"{0} {1}\",10,20); // C#
5条回答
  •  误落风尘
    2021-02-05 00:57

    There is a Printf module in GHC.

    import Text.Printf
    str :: String
    str = printf "%d %d" 10 20
    

    however it is probably simpler to just do

    str = show 10 ++ " " ++ show 20
    

提交回复
热议问题