Skip to content

Commit

Permalink
added fisher yates random shuffle method without using IO monads
Browse files Browse the repository at this point in the history
  • Loading branch information
firephil committed Mar 17, 2021
1 parent 3f8ed5b commit bb0e17d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
23 changes: 12 additions & 11 deletions Haskell-Algorithms.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ executable Haskell-Algorithms

-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>=4.14.1.0,
time >=1.1,
random >=0.1,
array >= 0.5,
MonadRandom >= 0.5,
containers >= 0.1

other-modules: Timer,
Mergesort,
Quicksort,
ShuffleList
build-depends: base ^>=4.14.1.0,
time >=1.1,
random >=0.1,
array >= 0.5,
MonadRandom >= 0.5,
containers >= 0.1

other-modules: Timer,
Mergesort,
Quicksort,
ShuffleList,
STshuffle

hs-source-dirs: app
default-language: Haskell2010
7 changes: 5 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import Mergesort(mergeSort)
import System.Random
import Control.Monad.Random

import ShuffleList(shuffle,fisherYates )
import ShuffleList(shuffle)
import STshuffle(st_shuffle)

ls = [1..8000]
rev = reverse ls
xs = fisherYates ls
--xs = st_shuffle ls


main :: IO ()
main = do

values <- evalRandIO(shuffle ls) -- store Random[[Int]] to values list (unwrap monad)
execute (quicksort values)
execute (mergeSort values)
Expand Down

0 comments on commit bb0e17d

Please sign in to comment.