소스 검색

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

George C. Privon 1 년 전
부모
커밋
863a27cf07
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  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.