For example if I defined F x y as a currying function and in an environment the partial function (F x) is used a lot, should i always let binding it to a named function in terms of performance? (say, compared to cached a property of an object, as it is often unnecessary to cache the property such as Array.Length)
let Gofrom (board: int[][]) (color: int) (reelID, reelPosition) (direction: Direction) =
let rec walkfrom x =
match direction.Target x with
| (a, _ | _, a) when a = -1 || a = board.Length -> x
| a, b when board.[a].[b]= color -> walkfrom (a, b)
| _ -> x
walkfrom (reelID, reelPosition)
v.s.
let rec Gofrom (board: int[][]) (color: int) (reelID, reelPosition) (direction: Direction) =
match direction.Target (reelID, reelPosition) with
| (a, _ | _, a) when a = -1 || a = board.Length -> (reelID, reelPosition)
| a, b when board.[a].[b]= color -> Gofrom board color (a, b) direction
| _ -> (reelID, reelPosition)
There should be no difference in performance, but I would definitely use the first form since it makes clear which args do not change between invocations.
Incidentally, this isn’t really about currying as you’re refactoring code into a separate function (closure) to avoid passing args around.