I'm a complete noob to Haskell I cant get my code working at all and i have no clue on how to fix it! I need help :) If someone has an idea of where i need to look in order to fix my issue i would be extremly greatful for ideas and nudges in the right direction.
I am trying to create a type of C# string.Format that repeats until a list is finished. The list is created by the userinput and then i just want a string to be repeated untill the list is finished.
test :: Integer -> String
let list_n [0..k]
test k = putStrLn (r * r) | r <- list_n --My idea here is that i am forcing
--the entire list onto r and making it repeated as long as there is more in the
--list, But im not even sure that is possible :(
Anyone has a better idea on how to do this? I want all the results in a line and not a row therefore im trying to create ittereration but in HaskeLL that is easier said then done :/
Here are two proposals; one tries to match the code you posted, and the other tries to match the English you posted. This seems to be mostly a question about syntax, so I'm not sure there's a lot of meaningful explanation that can go along with this other than "read a tutorial".
-- match the code
test :: Int -> String
test k = concat [show (r * r) | r <- [0..k]]
-- match the English
test :: Int -> String -> String
test k s = concat [s | r <- [0..k]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With