From 2e9d5613c5dc9ce421e44119da578405f797fdf4 Mon Sep 17 00:00:00 2001 From: Sanchime Date: Sun, 20 Feb 2022 17:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E9=87=8C=E5=8C=96=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Basic-practice-of-FSharp.fsproj | 36 +++++++++---------- Basic-practice-of-FSharp/CurryingFunction.fs | 15 ++++++++ 2 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 Basic-practice-of-FSharp/CurryingFunction.fs diff --git a/Basic-practice-of-FSharp/Basic-practice-of-FSharp.fsproj b/Basic-practice-of-FSharp/Basic-practice-of-FSharp.fsproj index 92d7716..576155b 100644 --- a/Basic-practice-of-FSharp/Basic-practice-of-FSharp.fsproj +++ b/Basic-practice-of-FSharp/Basic-practice-of-FSharp.fsproj @@ -1,18 +1,18 @@ - - - - Exe - net6.0 - Basic_practice_of_FSharp - - - - - - - - - - - - + + + Exe + net6.0 + Basic_practice_of_FSharp + + + + + + + + + + + + + \ No newline at end of file diff --git a/Basic-practice-of-FSharp/CurryingFunction.fs b/Basic-practice-of-FSharp/CurryingFunction.fs new file mode 100644 index 0000000..54e30b5 --- /dev/null +++ b/Basic-practice-of-FSharp/CurryingFunction.fs @@ -0,0 +1,15 @@ +module CurryingFunction + +// 科里化函数 +// 如果一个函数提供的参数数量少于指定的参数数量, 则可创建一个应采用其余参数的新函数 +// 这种处理参数的方法称为科里化, F#就提供了这种方法 + +// 提供一个二元函数add +let add a b = a + b + +// 假设你使用过程中,有明确的第二个参数的值,且是固定值,则可使用科里化 +let add_one = add 1 + +// 使用add_one只需提供一个参数 + +add_one 10 |> printfn "%d" // 将输出11