Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
$"{1000:n}"
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'
new Intl.NumberFormat().format(1000);
String.format("%,d", 1000000);
echo number_format(1000);
sub commify {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
'{:,}'.format(1000)
f'{1000:,}'
format(1000, ',')
'1000'.reverse.scan(/.{1,3}/).join(',').reverse
'1000'.gsub(/\B(?=(...)*\b)/, ',')
"%,d".format(n)