Language:EN
Pages: 4
Words: 542
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
5 tukeysninther  ord a num a  a  a

CPS506 Lab 5 Haskell: Functions & type signatures

In the provided source file called Lab5.hs you will implement each of the functions described below. All functions written for this lab must be placed in this single module. Make sure each of your functions is named precisely according to the specifications below, and the type signature is not modified in any way. You can test your code by running ‘cabal test’ from the lab5 directory (same idea as an Elixir mix project)

STEP BY STEP ANSWER WITH EXPLANATION

Below is the explanation for the implementations for each function described in the lab:

1. third_last :: [a] -> a

2. every_other :: [a] -> [a]

every_other :: [a] -> [a]

every_other [] = []

3. is_cyclops :: Int -> Bool

is_cyclops n = let s = show n

len = length s

4. domino_cycle :: [(Int, Int)] -> Bool

domino_cycle [] = True

domino_cycle ds = all (uncurry (==)) (zip (map snd ds) (map fst (tail ds ++ [head ds])))

5. tukeys_ninther :: (Ord a, Num a) => [a] -> a

medianOfThree xs = sort xs !! 1

tukeys_ninther :: (Ord a, Num a) => [a] -> a

chunksOf _ [] = []

chunksOf n xs = take n xs : chunksOf n (drop n xs)

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : DM_Me

PageId: DOC6E87D0E