Defining pointfree-style functions in functional programming. What are the cons / pros?

Every time I write something from a form

let scorePopulation f population =
  Array.map (fun i -> f i) population

Ultimately, I ask myself if it’s better to write

let scorePopulation f =
  Array.map (fun i -> f i)

instead of this. Is there an advantage in writing it in the first form, and not in the second?

Also, what would you call a function definition in the first form and in the second form?

+5
source share
6 answers

You can go even further:

let scorePopulation = Array.map

/, , , , . , , . , .

+12

: .

:

. .

(.. ), . , - , .

.

, .

- , .

+10

, - . ? .

, : [MSDN]. . , .

+7

. .

. , . :

, . ( ) .

, .

+6

, . ,

, .

, , "" , . (, , / - , .)

, " " , , , F #.

+5

, . , , : i) ii) . ,

let f = function [] -> "empty" | x::_ -> "not empty"

let f l = match l with [] -> "empty" | x::_ -> "not empty"

let f = List.map g |> List.fold_left h

let f l = List.map g (List.fold_left h l)

. , |>, .

+2

All Articles