s :: Int -> String
s = intersperseN ',' 3 . show
intersperseN :: a -> Int -> [a] -> [a]
intersperseN x n = uncurry (<>) . foldr alg ([], [])
where
alg a (buf', acc)
| length buf >= n = ([], (x:buf) <> acc)
| otherwise = (buf, acc)
where buf = a:buf'
String.format("%,d", 1000000);
import java.text.DecimalFormat;
DecimalFormat decimalFormat = new DecimalFormat("#,###");
String formattedString = decimalFormat.format(1000000);
s :: Int -> String
s = intersperseN ',' 3 . show
intersperseN :: a -> Int -> [a] -> [a]
intersperseN x n = uncurry (<>) . foldr alg ([], [])
where
alg a (buf', acc)
| length buf >= n = ([], (x:buf) <> acc)
| otherwise = (buf, acc)
where buf = a:buf'