Difference between revisions of "FP Homework 4"

From Marek Běhálek Wiki
Jump to navigation Jump to search
(Created page with "== Arrays and vectors in Haskell== == 1 - Bubble sort == * Create a function, that sorts an array using quicksort algorithm. <syntaxhighlight lang="Haskell">quickSort :: Ar...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
== Arrays and vectors in Haskell==  
 
== Arrays and vectors in Haskell==  
  
== 1 - Bubble sort ==  
+
== 1 - Quicksort ==  
* Create a function, that sorts an array using quicksort algorithm.
+
* Create a function, that sorts an array using quicksort algorithm [https://en.wikipedia.org/wiki/Quicksort <code>quicksort</code>]. Inside, you must use the mutable array [https://hackage.haskell.org/package/array-0.5.4.0/docs/Data-Array-ST.html#t:STArray <code>STArray</code>].
 
<syntaxhighlight lang="Haskell">quickSort :: Array Int Int -> Array Int Int</syntaxhighlight>
 
<syntaxhighlight lang="Haskell">quickSort :: Array Int Int -> Array Int Int</syntaxhighlight>
 
<syntaxhighlight lang="Haskell" class="myDark">
 
<syntaxhighlight lang="Haskell" class="myDark">

Latest revision as of 13:16, 4 November 2022

Arrays and vectors in Haskell

1 - Quicksort

  • Create a function, that sorts an array using quicksort algorithm quicksort. Inside, you must use the mutable array STArray.
quickSort :: Array Int Int -> Array Int Int
ghci> elems $ quickSort $  listArray (0,5) [8,4,9,6,7,1] 
[1,4,6,7,8,9]