I was trying to recursively pass a function to itself a given number of times. So given the input in form of Function | RepeatNumber(Count) | Argument. So as an example if given the input: f 3 2 it would return f(f(f 2) This should then also work if the Function value where "square" it would Square the argument.
In terms of the logic I approached it as follows:
def repeatnew func count arg
if count == 1 then (func arg)
else (func (repeatnew func (count -1) arg))
I've been trying to research a solution to this for a while and I came across using Iterate and some other functions. Finally I came across this: https://wiki.haskell.org/Higher_order_function However I was unable to implement a working solution.
Edit: The solutions I did try to implement I could get compiling correctly, I am still very inexperienced with haskell and would appreciate an explanation on how to create a higher order function using my parameters.
I was unable to implement a working solutionWhat was your specific issue that prevented your solution from working? What actual code did you try?fpow f n x = iterate f x !! nrepeatFun :: Char -> Int -> Char -> String repeatFun func count arg repeatFun = (count-1)*((func)+(arg)) repeatFun = func (repeatFun func (count-1) arg)I am new to haskell so my implementation skills are seriously lacking