Question: use haskell to solve below questions: 4 pts) Implement a search algorithm that searches through a list for Int n and returns the value in
use haskell to solve below questions:
4 pts) Implement a search algorithm that searches through a list for Int n and returns the value in the list after n. If there is no value, or the list is empty, return -1. E.g., findNext 5 [1,2,3,4,5,6] should return 6, while findNext 5 [0, 10, 20, 30] returns -1.
2 pts) Implement a search algorithm that searches through a list for Int n and returns the value in the list before n. If there is no value, or the list is empty, return -1. E.g., findPrev 5 [1,2,3,4,5,6] should return 4, while findPrev 5 [0, 10, 20, 30] returns -1.
4pts) Implement function that calculates a digit sum of an Int --- adds all the digits of the int together, returning an Int. You can define a second helper function. At least one of your functions must use recursion.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
