Question
1.Write a Haskell function asciisum that uses recursion to compute the sum of the ASCII values in a String. asciisum :: String -> Integer 2.
1.Write a Haskell function asciisum that uses recursion to compute the sum of the ASCII values in a String. asciisum :: String -> Integer
2. Write a function integerSqrt that returns the integer square root of a positive integer n. (The integer square root is dened to be the largest integer whose square is less than or equal to n, i.e. the result of integerSqrt 15 is 3.). integerSqrt :: Integer -> Integer
3. Write a function matches that picks out all instances of an integer n from a list. (Example: matches 3 [3,4,5,3] should return [3,3] and matches 3 [4,5,7] should return [].). matches :: Integer -> [Integer] -> [Integer]
4. Use the matches function in the above problem to write a function element that returns True if an element is a member of a list, False otherwise. (You may not use the elem function that is already dened in Haskell.). element :: Integer -> [Integer] -> Bool
5. Write a recursive function elemAt that returns the item of the list, where the rst item is index 0. You may not use any of the standard Haskell functions that operate on lists. elemAt :: Int -> [Int] -> Int
6. Write a function and' that uses recursion to return the conjunction of a list of boolean values. and' :: [Bool] -> Bool
7. Write a function iSort' that uses insertion sort to sort a list of pairs (Int, String) where only the rst element (the Int part of the pair) is to be considered during the sorting process. iSort' :: [(Int, String)] -> [(Int, String)]
8. Write a function upperFirstTwoLetters that uppercases the rst two letters in a string but and leaves everything else as is. upperFirstTwoLetters :: String -> String
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started