From df29cfc676a16d25c4246243b0d5cf431545b430 Mon Sep 17 00:00:00 2001 From: lucas8485 <1443937075@qq.com> Date: Sun, 14 Aug 2022 19:17:28 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=96=BD=E5=B7=A5=E9=98=B6=E6=AE=B54?= =?UTF-8?q?=EF=BC=9A=E9=80=89=E6=8B=A9=E6=8E=92=E5=BA=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8ee64b0fa9d04e47aaaf3af05a29d0dfff2cdf09. --- .gitignore | 3 +-- Algorithm-FSharp/Algorithm-FSharp.fsproj | 32 +++++++++++++----------- Algorithm-FSharp/IntersectionSort.fs | 23 ----------------- Algorithm-FSharp/Program.fs | 4 +-- Algorithm-FSharp/TestList.fs | 3 --- 5 files changed, 20 insertions(+), 45 deletions(-) delete mode 100644 Algorithm-FSharp/IntersectionSort.fs diff --git a/.gitignore b/.gitignore index 7c4f36a..add57be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ bin/ obj/ /packages/ riderModule.iml -/_ReSharper.Caches/ -.fake \ No newline at end of file +/_ReSharper.Caches/ \ No newline at end of file diff --git a/Algorithm-FSharp/Algorithm-FSharp.fsproj b/Algorithm-FSharp/Algorithm-FSharp.fsproj index a8cb50f..fe7fd8a 100644 --- a/Algorithm-FSharp/Algorithm-FSharp.fsproj +++ b/Algorithm-FSharp/Algorithm-FSharp.fsproj @@ -1,15 +1,17 @@ - - - Exe - net6.0 - Algorithm_FSharp - - - - - - - - - - \ No newline at end of file + + + + Exe + net6.0 + Algorithm_FSharp + + + + + + + + + + + diff --git a/Algorithm-FSharp/IntersectionSort.fs b/Algorithm-FSharp/IntersectionSort.fs deleted file mode 100644 index 28e1b8f..0000000 --- a/Algorithm-FSharp/IntersectionSort.fs +++ /dev/null @@ -1,23 +0,0 @@ -module Algorithm_FSharp.IntersectionSort -// 将一个元素插入到有序序列中 -// intersect : 'a -> 'a list -> 'a list -let rec intersect elem = function - | [] -> [elem] // 若序列为空,则无需比较,直接将元素插入到空序列中 - | x::xs -> // 若序列不为空 - match x < elem with // 取出序列中的第一个元素x,并将其与待插入元素比较 - | true -> // 若x小于待插入元素 - match xs with // 判断xs是否为空 - | [] -> [elem; x] // 若xs为空,则直接插入到elem后部即可 - | y::ys -> // 若xs不为空,则切割xs为有序序列的第二个元素y和剩余元素ys - match elem < y with // 再比较elem和y - | true -> [x; elem; y] @ ys // 若x < elem < y,则插入位点位于x、y之间 - | false -> x::(xs |> intersect elem) // 若elem > y,则插入位点无法决议,递归插入 - | false -> elem::x::xs // 若待插入元素小于序列中第一个元素,则直接插入到序列头部即可 -// 插入排序的F#实现 -// intersection_sort : 'a list -> 'a list -let rec intersection_sort = function - | [] -> [] // 若待排序序列为空或只有一个元素,则它已经有序,直接返回 - | [single] -> [single] - | x::xs -> xs // 若待排序序列有多个元素,则取出第一个元素 - |> intersection_sort // 递归对后续序列进行排序 - |> intersect x // 然后将第一个元素插入到序列中 \ No newline at end of file diff --git a/Algorithm-FSharp/Program.fs b/Algorithm-FSharp/Program.fs index 6ba9a3d..932d55d 100644 --- a/Algorithm-FSharp/Program.fs +++ b/Algorithm-FSharp/Program.fs @@ -1,8 +1,8 @@ // For more information see https://aka.ms/fsharp-console-apps module Algorithm_FSharp.Program -open Algorithm_FSharp.IntersectionSort +open Algorithm_FSharp.QuickSort open Algorithm_FSharp.TestList // 测试用例 printfn $"%A{myList - |> intersection_sort}" + |> quicksort}" diff --git a/Algorithm-FSharp/TestList.fs b/Algorithm-FSharp/TestList.fs index 8f4d968..9416c1a 100644 --- a/Algorithm-FSharp/TestList.fs +++ b/Algorithm-FSharp/TestList.fs @@ -37,9 +37,6 @@ let myList = [ 512 652 111 - 233 - 233 - 233 851 98 277