recursion - Abstracting a loop -
I sometimes feel like writing a loop within my work (recursive work) it creates weird codes like this Is:
value = REC loop one = if ... then another loop AB loop a I know I go can move the loop out of the binding, but it is the only objective to calculate tied value. So I thought I could summarize the loop in a different function:
let's go f = a rq a = a = match with f a. Some B - & gt; Aux B None - & gt; One aux a I could then:
value = one |> Maybe it's better - at least this function is more than definition As an assignment I & lt; These are my questions: - Is there a recursive function in
Is there any compulsion for any code odor? - Is there a better way of refactor
- If not, can my
loop function be normalized, or improved in some way?
- No
- I think what you are doing, I got it Is okay
-
Here's how I do it:
REC loop guard step init = if guard init then init else loop guard step step init) Assume = a | & Gt; Loop (funny - & gt; ...) (funny - - gt; a.b)
Comments
Post a Comment