September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,17 +1,20 @@
on run
nreps("ha", 50000)
end run
replicate(5000, "ha")
-- Repetition by 'Egyptian multiplication' -
-- progressively doubling a list, appending
-- stages of doubling to an accumulator where needed for
-- binary assembly of a target length.
-- String -> Int -> String
on nreps(s, n)
set o to ""
if n < 1 then return o
-- replicate :: Int -> String -> String
on replicate(n, s)
set out to ""
if n < 1 then return out
set dbl to s
repeat while (n > 1)
if (n mod 2) > 0 then set o to o & s
if (n mod 2) > 0 then set out to out & dbl
set n to (n div 2)
set s to (s & s)
set dbl to (dbl & dbl)
end repeat
return o & s
end nreps
return out & dbl
end replicate