Question
Please implement some haskell code below. Thanks Implement a search algorithm that searches through a list for Int n and returns the value in the
Please implement some haskell code below. Thanks
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.
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.
Implement a 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
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