Selaa lähdekoodia

exercise 5.4: Int -> [Int] function with explanation

George C. Privon 1 vuosi sitten
vanhempi
commit
863a27cf07
1 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 15 0
      05-Lists/exercises/ex5.4.hs

+ 15 - 0
05-Lists/exercises/ex5.4.hs

@@ -0,0 +1,15 @@
+-- Exercise 5.4
+-- George C. Privon
+-- 2024-07-20
+
+repeatInt :: Int -> [Int]
+repeatInt n = n:n:n:[]
+
+-- `repeatInt` takes an input integer and returns a list of three copies of
+-- that integer.
+
+tripleString :: String -> [String]
+tripleString stng = stng:stng:stng:[]
+
+-- `tripleString` takes an input string and returns a list of three copies of
+-- that string.