If Array.append has no partially mutable arguments, then lambda can be removed

I have an array of string arrays. I need to smooth them out and I use:

Array.fold (fun acc el -> Array.append acc el) [||] arr2d 

Lint tells me that:

"If Array.append has no partially mutable arguments, then lambda can be removed"

What does it mean? How to remove lambda?

+5
source share
1 answer

Any lambda function in this form (fun x -> fx) can be expressed as f . Keeping the same state.

In your code, you have fun acc el -> Array.append acc el , which is of the same type and does the same as Array.append , so you can shorten it to:

 Array.fold Array.append [||] arr2d 
+9
source

Source: https://habr.com/ru/post/1236720/


All Articles