tags:

views:

114

answers:

2

What is haskell equivalent of

string str = string.Format("{0} {1}",10,20); // C#
+10  A: 

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
newacct
Its not working I got `ERROR filename.hs:3:Cannot justify constraints in explicitly typed binding`. I am using WinHugs.
TheMachineCharmer
You should switch to GHC. Hugs is unmaintained, slow, and supports very few of the packages on Hackage. It isn't part of the Haskell Platform specification either.
Don Stewart
+1  A: 

Is this what you are looking for?

printf "%d %d" 10 20

See Text.Printf.

Oded