例如,如果我定义F x y
为柯里化函数并且在环境(F x)
中使用了很多部分函数,let binding
那么就性能而言,我是否应该始终将其用于命名函数?(例如,与缓存的 a 相比,property
通常object
不需要缓存 like )property
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)
对比
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)