Repeat a string: Difference between revisions
Content added Content deleted
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
(→{{header|JavaScript}}: Updated primitives) |
||
Line 924: | Line 924: | ||
See the technique of 'Egyptian Multiplication' described in the Rhind Mathematical Papyrus at the British Museum. |
See the technique of 'Egyptian Multiplication' described in the Rhind Mathematical Papyrus at the British Museum. |
||
<lang javascript> |
<lang javascript>(() => { |
||
'use strict'; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
return o + s; |
|||
} |
|||
// replicate :: Int -> String -> String |
|||
nreps('ha', 50000);</lang> |
|||
const replicate = (n, s) => { |
|||
let v = [s], |
|||
o = []; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
v = v + v; |
|||
⚫ | |||
return o.concat(v); |
|||
⚫ | |||
return replicate(5000, "ha") |
|||
})();</lang> |
|||
=={{header|jq}}== |
=={{header|jq}}== |