Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding two code examples for the Haskell language #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 1_hello_world/hello_world.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
main = do
--This line prints the String "Hello, World."
putStr "Hello, World."
--Define a variable within this do-block.
let myVar = "Hello World"
--Print the contents of the variable on the screen.
putStr myVar
13 changes: 13 additions & 0 deletions 9_quick_sort/quick_sort.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
quicksort :: [Int] -> [Int]
quicksort [] = []
quicksort (x:xs) = (quicksort leftSide) ++ [x] ++ (quicksort rightSide)
where leftSide = filter (<x) xs
rightSide = filter (>=x) xs

--
main = do
putStrLn "Awaiting Integer list like: [1,3,6,42,...]"
myArray <- getLine
let toSort = read myArray :: [Int]
putStrLn "The sorted array is:"
putStrLn $ show $ quicksort toSort