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

3
.gitignore vendored
View File

@ -2,5 +2,4 @@ bin/
obj/ obj/
/packages/ /packages/
riderModule.iml riderModule.iml
/_ReSharper.Caches/ /_ReSharper.Caches/
.fake

View File

@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <OutputType>Exe</OutputType>
<RootNamespace>Algorithm_FSharp</RootNamespace> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> <RootNamespace>Algorithm_FSharp</RootNamespace>
<ItemGroup> </PropertyGroup>
<Compile Include="IntersectionSort.fs" />
<Compile Include="TestList.fs" /> <ItemGroup>
<Compile Include="SelectionSort.fs" /> <Compile Include="TestList.fs" />
<Compile Include="MergeSort.fs" /> <Compile Include="SelectionSort.fs" />
<Compile Include="QuickSort.fs" /> <Compile Include="MergeSort.fs" />
<Compile Include="Program.fs" /> <Compile Include="QuickSort.fs" />
</ItemGroup> <Compile Include="Program.fs" />
</Project> </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 // For more information see https://aka.ms/fsharp-console-apps
module Algorithm_FSharp.Program module Algorithm_FSharp.Program
open Algorithm_FSharp.IntersectionSort open Algorithm_FSharp.QuickSort
open Algorithm_FSharp.TestList open Algorithm_FSharp.TestList
// //
printfn $"%A{myList printfn $"%A{myList
|> intersection_sort}" |> quicksort}"

View File

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