I have a list of values ββthat I would like to use while the value is increasing. I assume that he will always top the list and then compare it with the next value. The function will continue as long as it continues to increase. Upon reaching the list item that is less than or equal to the desired value, the list is returned.
takeIncreasing :: (Ord a) => [a] -> [a] takeIncreasing [1,2,3,4,3,5,6,7,8] -- Should return [1,2,3,4]
A summary can compare the last accumulation element with the next value and add if the condition is met, but will continue to the end of the list. I would like the function to stop accepting in the first case the restriction was not fulfilled.
This is similar to a monad application, but cannot determine if the existing monad does this.
list functional-programming haskell
Ben Campbell Apr 19 '16 at 2:27 2016-04-19 02:27
source share