Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write below functions in HASKELL functional programming language and remember to include both the (1) function declaration, and (2) function definition. Write a function
Please write below functions in HASKELL functional programming language and remember to include both the (1) function declaration, and (2) function definition.
- Write a function sumLastPart which, only using library functions, returns the sum of the last n numbers in the list, where n is the first argument to the function. sumLastPart :: Int -> [Int] -> Int
- Write a function init' that has identical behavior to the init function. In your definition, you may only use the standard Haskell functions that operate on lists (except for init). init' :: [Int] -> [Int]
- Write a recursive function init'' that has the same behavior as init'. No standard Haskell functions may be used. init'' :: [Int] -> [Int]
- Write a recursive function elemAt that returns the ith item of the list, where the first item is index 1. You may not use any of the standard Haskell functions that operate on lists. elemAt :: Int -> [Int] -> Int
- Write a function numTimes that returns the number of times that an element occurs in the list. Use recursion, not a list comprehension. numTimes :: Int -> [Int] -> Int
- Write a function lowerFirstLetter that lowercases the first and only first letter of a string. lowerFirstLetter :: String -> String
- Write a function and' that uses recursion to return the conjunction of a list of boolean values. and' :: [Bool] -> Bool
- Write a function or' that uses recursion to return the disjunction of a list of boolean values. or' :: [Bool] -> Bool
- Write a function iSort' that uses insertion sort to sort a list of triples (Float, Int, String) where only the second element (the Int part of the triple) is to be considered during the sorting process. iSort' :: [(Float, Int, String)] -> [(Float, Int, String)]
- Write a function merge that takes two sorted lists (decreasing order) and merges them into a single sorted list (decreasing order). merge :: [Int] -> [Int] -> [Int]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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