Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

****ALL MUST BE DONE IN HASKELL****** 1. 2pts) Create a function, usingpartial application of functions, that sees if a single Int is divisible by 5.

****ALL MUST BE DONE IN HASKELL****** 1. 2pts) Create a function, usingpartial application of functions, that sees if a single Int is divisible by 5. It takes in an Int and returns a Bool. (edited from original to be a bit easier)

2. 2pts) Write a function that checks if every other letter of a string is between 'a' and 'f' (the remaining letters don't matter, start with the first letter in the string, skip the second, and so on). The function takes in a String and returns a Bool. Use partial application at least once.Empty string returns True. (edited to specify what empty string returns, some clarification added).

3. 4pts) Write a function that takes two lists, zips them, then maps the result to a list of sums of the numbers in the tuples. E.g., [1, 2, 3] [4, 5, 6] gets zipped to [(1, 4), (2, 5), (3,6)], then gets mapped to [5, 7, 9].

4. 4pts) Write a function that maps a list of Strings that may have multiple words to Strings with only the first word left. E.g. ["Today is Thursday", "Banquet", "unreal games"] becomes ["Today", "Banquet", "unreal"].

5. 4pts) Write a function that takes a two dimensional matrix of Strings and transforms all empty strings to "0".

6. 4pts) Write a function that converts [a, b, c, d, . . . ] to [(a,b), (c, d), . . .], where a, b, c, and d can be any type.

7. 2pts) Using the previous function, convert eachtupleto a product of its two elements, using foldl and a lambda expression.

8. 1pt) Using scanl, write a function that takes a list of Ints and make a list of cumulative sums.

9. 1pt) Consider this function:

applyThrice :: (Int -> Int) -> Int -> Int applyThrice f x = f (f (f x))

Use $ to make the second line more readable

10. 2pts) Convert:

isLowerCase :: Char -> Bool isLowerCase x = x `elem` ['a' .. 'z']

to point free style

11. 4pts) Sort a list of Strings by length of the first word in the strings (if the strings have more than one word)

5pts) Pack repeats in a list of Charsinto separate lists, resulting in a sorted list of lists: E.g.,

['a', 'a', 'a', 'a', 'b', 'c', 'c', 'a', 'a', 'd', 'e', 'e', 'e', 'e'] becomes ["aaaaaa","b","cc","d","eeee"]

Use whatever techniques you know so far. (Note, this is amodifiedversion of an online problem, so solutions to that problem, should you Google it, won't work here).

Copyright 2012-2017, Chengyu Sun. All rights reserved

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions