Merge pull request #172 from seanyu4296/add-purescript-solution-for-chapter-1-chapter-2

Add purescript solution for chapter 1 chapter 2
This commit is contained in:
Aditya Bhargava
2020-09-14 12:52:10 -05:00
committed by GitHub
8 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# Getting Started
1. Install `spago` and `purescript` through `yarn` or `npm` (e.g. `yarn global add spago` and `yarn global add purescript`)
2. Run file through `spago run --watch --main <module-name>` (e.g. `spago run --watch --main GrokkingAlgos.SelectionSort`)
# Main Repo
- https://github.com/seanyu4296/grokking-algo-in-purs

View File

@@ -0,0 +1,17 @@
module GrokkingAlgos.SelectionSort where
import Prelude
import Data.Foldable (minimum)
import Data.List (List(..), delete, (:))
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Class.Console (logShow)
selectionsort :: List Int -> List Int
selectionsort l = case minimum l of
Nothing -> Nil
Just min -> min : selectionsort (delete min l)
main :: Effect Unit
main = do
logShow $ selectionsort $ 1 : 2 : 3 : 5 : 4 : Nil

View File

@@ -0,0 +1,8 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200724/packages.dhall sha256:bb941d30820a49345a0e88937094d2b9983d939c9fd3a46969b85ce44953d7d9
let overrides = {=}
let additions = {=}
in upstream // overrides // additions

View File

@@ -0,0 +1,9 @@
{-
Welcome to a Spago project!
You can edit this file as you like.
-}
{ name = "my-project"
, dependencies = [ "console", "effect", "psci-support", "arrays", "debug", "lists", "ordered-collections", "strings"]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}