Revert "施工阶段4:选择排序"

This reverts commit 8ee64b0fa9.
This commit is contained in:
_Karasu_ 2022-08-14 19:17:28 +08:00
parent 8ee64b0fa9
commit df29cfc676
5 changed files with 20 additions and 45 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@ obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
.fake

View File

@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Algorithm_FSharp</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="IntersectionSort.fs" />
<Compile Include="TestList.fs" />
<Compile Include="SelectionSort.fs" />
<Compile Include="MergeSort.fs" />
<Compile Include="QuickSort.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Algorithm_FSharp</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="TestList.fs" />
<Compile Include="SelectionSort.fs" />
<Compile Include="MergeSort.fs" />
<Compile Include="QuickSort.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
</Project>

View File

@ -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] // xselem
| y::ys -> // xsxsyys
match elem < y with // elemy
| true -> [x; elem; y] @ ys // 若x < elem < yxy
| 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 //

View File

@ -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}"

View File

@ -37,9 +37,6 @@ let myList = [
512
652
111
233
233
233
851
98
277