Jan Return 3

This page is a review of some Haskell essentials.

  1. Return a list of all of the numbers in a list that are smaller than a given limit.

     smallOnes :: Int -> [Int] -> [Int]
     smallOnes cutoff xs = undefined
     checks1 = [smallOnes 8 [30,-10,-7,3,5,8,50] == [-10,-7,3,5]]
    
  2. Return the input list, except with every occurrence of a given number repeated 4 times.

     fourX :: Int -> [Int] -> [Int]
     fourX given xs = undefined
     checks2 = [fourX 9 [1,2,9,3,4,9] == [1,2,9,9,9,9,3,4,9,9,9,9],
                fourX 1 [1,2,3] == [1,1,1,1,2,3]]
    
  3. Output only the numbers with the same tens digit as the given digit.

     keep10 :: Int -> [Int] -> [Int]
     keep10 digit xs = undefined
     checks3 = [keep10 4 [-16,40,34,41,431,134,341,10240] == [40,41,341,10240]]
    

Animation

Omit this part.

(Class description available.)

Example video on YouTube.

Starter code:

{-# LANGUAGE OverloadedStrings #-}
import CodeWorld
import Data.Text as T
Last modified August 18, 2023: 2022-2023 End State (7352e87)