Question: I already made a code that does this method through recursion. However, I am unable to do the example maxFuncChain 0 [(fun x -> x

 I already made a code that does this method through recursion.

I already made a code that does this method through recursion. However, I am unable to do the example

maxFuncChain 0 [(fun x -> x - 1); (fun x -> x * -500); (fun x -> x + 1)] = 501 

I'm comparing the result I get from running a function with the original number (without the function), then returning the result with the function ran on it if that result is larger than the original one. This made it so that the example I gave above kept returning 1 instead of 501. What other recursive methods can check for negative values, while also checking for positive values from the functions like from the example above?.

- Description: MaxProcChain from Project 1a makes its return, OCaml style! This function takes in an initial value and a list of functions, and decides to either apply each function or not to maximize the final return value. For example, if I have a list of functions: funcc] and an initial value x, then I take the maximum value of - Type: 'a ('a 'a) list 'a - Examples: maxFuncChain 2[( fun xx+6)]=8 maxFuncChain2[( fun xx+4); (fun xx4)]=24 maxFuncChain4[( fun xx2);( fun xx+10)]=14 maxFuncChain[( fun xx1); (fun xx500);( fun xx+1)]=501 maxFuncChain "hello" [( fun xx"1"); (fun xx"2");(funxx"3")]=" "hello3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!