F# and C# addings (#189)

* F# - Binary Search

* C# - Double selection sort

* quick sort - f#
This commit is contained in:
Tassadar2499
2021-03-14 20:43:28 +05:00
committed by GitHub
parent fec65db129
commit 36accc72c6
3 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// Learn more about F# at http://fsharp.org
open System
[<EntryPoint>]
let main argv =
let numbers = [|3; 9; 10; 1; 4; 2; 6; 5; 8; 7|]
let rec quickSort(arr: int[]) =
if arr.Length < 2
then arr
else
let pivot = arr.[0]
let arrExcpetPivot = arr |> Seq.skip(1) |> Seq.toArray
let lessElements = quickSort arrExcpetPivot |> Seq.filter(fun n -> n <= pivot) |> Seq.toArray
let greaterElements = quickSort arrExcpetPivot |> Seq.filter(fun n -> n > pivot) |> Seq.toArray
Seq.append (Seq.append lessElements [|pivot|]) greaterElements |> Seq.toArray
let sorted = quickSort(numbers)
0