Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
concat $ replicate 5 "ha"

View file

@ -0,0 +1 @@
[1..5] >> "ha"

View file

@ -0,0 +1 @@
[1..5] *> "ha"

View file

@ -0,0 +1 @@
cycle "ha"

View file

@ -0,0 +1 @@
replicate 5 '*'

View file

@ -0,0 +1,9 @@
repString :: String -> Int -> String
repString s n =
let rep x = xs
where
xs = mappend x xs
in take (n * length s) (rep s)
main :: IO ()
main = print $ repString "ha" 5

View file

@ -0,0 +1,25 @@
import Data.Tuple (swap)
import Data.List (unfoldr)
import Control.Monad (join)
-- BY RHIND PAPYRUS 'EGYPTIAN' OR 'ETHIOPIAN' MULTIPLICATION ------------------
repString :: Int -> String -> String
repString n s =
foldr
(\(d, x) a ->
if d > 0 -- Is this power of 2 needed for the binary recomposition ?
then mappend a x
else a)
mempty $
zip
(unfoldr
(\h ->
if h > 0
then Just $ swap (quotRem h 2) -- Binary decomposition of n
else Nothing)
n)
(iterate (join mappend) s) -- Iterative duplication ( mappend to self )
-- TEST -----------------------------------------------------------------------
main :: IO ()
main = print $ repString 500 "ha"