Advertisement
GerexD

hs-2-1

Jan 5th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. torol_szokoz :: String -> String
  3. torol_szokoz [] = []
  4. torol_szokoz (' ':xs) = torol_szokoz(xs)
  5. torol_szokoz (x:xs) = toLower x:torol_szokoz(xs)
  6.  
  7. string_buffer :: Int -> String
  8. string_buffer 0 = []
  9. string_buffer n = " " ++ string_buffer (n-1)
  10.  
  11. string_negyszog :: Int -> String -> [String]
  12. string_negyszog n s
  13. | length s>=n = take n s : string_negyszog n (drop n s)
  14. | length s>0 = [s ++ string_buffer (n-(length s))]
  15. | otherwise = []
  16.  
  17. string_oszlop :: Int -> Int -> [String] -> [String] -> String
  18. string_oszlop i n (x:xs) lista
  19. | i == n = ""
  20. | length xs == 0 && x!!i /= ' ' = [x!!i] ++ string_oszlop (i+1) n lista lista
  21. | length xs == 0 && x!!i == ' ' = string_oszlop (i+1) n lista lista
  22. | x!!i == ' ' = string_oszlop i n xs lista
  23. | otherwise = [x!!i] ++ string_oszlop i n xs lista
  24.  
  25. string_spacel :: Int -> Int -> String -> String
  26. string_spacel 0 _ string = string
  27. string_spacel _ _ [] = []
  28. string_spacel c i (x:xs)
  29. | c == i = [' '] ++ string_spacel c 0 (x:xs)
  30. | otherwise = x:string_spacel c (i+1) xs
  31.  
  32. string_kodol :: Int -> Int -> String -> String
  33. string_kodol 0 _ _ = []
  34. string_kodol _ _ [] = []
  35. string_kodol n c string = string_spacel c 0 string_raw
  36. where string_raw = (string_oszlop 0 n string_array string_array)
  37. where string_array = (string_negyszog n uj_string)
  38. where uj_string = (torol_szokoz string)
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement