Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Priority-queue/F-Sharp/priority-queue-4.fs
Normal file
19
Task/Priority-queue/F-Sharp/priority-queue-4.fs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
> let testseq = [| (3u, "Clear drains");
|
||||
(4u, "Feed cat");
|
||||
(5u, "Make tea");
|
||||
(1u, "Solve RC tasks");
|
||||
(2u, "Tax return") |] |> Array.toSeq
|
||||
let testpq = testseq |> MinHeap.fromSeq
|
||||
testseq |> Seq.fold (fun pq (k, v) -> MinHeap.push k v pq) MinHeap.empty
|
||||
|> MinHeap.toSeq |> Seq.iter (printfn "%A") // test slow build
|
||||
printfn ""
|
||||
testseq |> MinHeap.fromSeq |> MinHeap.toSeq // test fast build
|
||||
|> Seq.iter (printfn "%A")
|
||||
printfn ""
|
||||
testseq |> MinHeap.sort |> Seq.iter (printfn "%A") // convenience function
|
||||
printfn ""
|
||||
MinHeap.merge testpq testpq // test merge
|
||||
|> MinHeap.toSeq |> Seq.iter (printfn "%A")
|
||||
printfn ""
|
||||
testpq |> MinHeap.adjust (fun k v -> uint32 (MinHeap.size testpq) - k, v)
|
||||
|> MinHeap.toSeq |> Seq.iter (printfn "%A") // test adjust;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue