Answered step by step
Verified Expert Solution
Link Copied!

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.

  1. 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
  2. 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]
  3. Write a recursive function init'' that has the same behavior as init'. No standard Haskell functions may be used. init'' :: [Int] -> [Int]
  4. 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
  5. 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
  6. Write a function lowerFirstLetter that lowercases the first and only first letter of a string. lowerFirstLetter :: String -> String
  7. Write a function and' that uses recursion to return the conjunction of a list of boolean values. and' :: [Bool] -> Bool
  8. Write a function or' that uses recursion to return the disjunction of a list of boolean values. or' :: [Bool] -> Bool
  9. 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)]
  10. 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

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_2

Step: 3

blur-text-image_3

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

Students also viewed these Databases questions

Question

What advertising media and promotional tactics will you use?

Answered: 1 week ago

Question

2. How much time should be allocated to the focus group?

Answered: 1 week ago

Question

1. Where will you recommend that she hold the focus group?

Answered: 1 week ago