Repeat a string: Difference between revisions
m
→{{header|Haskell}}
Line 812:
<pre>"hahahahaha"</pre>
As the number of repetitions
<lang haskell>import Data.Tuple (swap)
Line 823:
foldr
(\(d, x) a ->
if d > 0 -- Is this power of 2 needed for the binary
then mappend a x
else a)
Line 831:
(\h ->
if h > 0
then Just $ swap (quotRem h 2) -- Binary decomposition of n
else Nothing)
n)
|