Compare commits
No commits in common. "66bcee129b8d82cc7ae8ba0ebd02345c192d01b3" and "855727ba1de8fdad4a2ed76155c004d4bf785b0f" have entirely different histories.
66bcee129b
...
855727ba1d
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
dist-newstyle
|
*.hi
|
||||||
|
*.o
|
||||||
|
Main
|
||||||
|
Problems
|
||||||
|
11
Dockerfile
11
Dockerfile
@ -1,11 +0,0 @@
|
|||||||
FROM haskell:9.2.8-slim-buster
|
|
||||||
|
|
||||||
WORKDIR /home/saundersp/haskell_playground
|
|
||||||
|
|
||||||
RUN cabal update
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN cabal build
|
|
||||||
|
|
||||||
ENTRYPOINT ["cabal", "run"]
|
|
@ -1,8 +1,7 @@
|
|||||||
import Problems ( myLast, lastTwo, kth, myLength, rev, isPalindrome, flatten, NestedList(..), compress, pack, encode )
|
import Problems ( myLast, lastTwo, kth, myLength, rev, isPalindrome, flatten, NestedList(..), compress, pack, encode )
|
||||||
--import Primes ( aspGetNextPrime, aspIsPrime, aspPrimes )
|
--import Primes ( aspGetNextPrime, aspIsPrime, aspPrimes )
|
||||||
import Primes ( aspGetNextPrime, aspIsPrime )
|
|
||||||
import Data.Numbers.Primes ( isPrime, primes, primeFactors )
|
import Data.Numbers.Primes ( isPrime, primes, primeFactors )
|
||||||
--import Math ( mandlebrot )
|
import Math ( mandlebrot )
|
||||||
|
|
||||||
-- Unit testing
|
-- Unit testing
|
||||||
main :: IO()
|
main :: IO()
|
||||||
@ -10,7 +9,7 @@ main = do
|
|||||||
testMisc
|
testMisc
|
||||||
testProblems
|
testProblems
|
||||||
testPrimes
|
testPrimes
|
||||||
--mandlebrot
|
mandlebrot
|
||||||
|
|
||||||
testMisc :: IO()
|
testMisc :: IO()
|
||||||
testMisc = do
|
testMisc = do
|
||||||
@ -38,7 +37,7 @@ testMisc = do
|
|||||||
putStrLn ("FizzBuzz 50 " ++ show (fizzBuzz [0..50]))
|
putStrLn ("FizzBuzz 50 " ++ show (fizzBuzz [0..50]))
|
||||||
|
|
||||||
putStrLn ("Fionacci 10 " ++ show (fibonacci 10))
|
putStrLn ("Fionacci 10 " ++ show (fibonacci 10))
|
||||||
putStrLn ("FionacciList 10 " ++ show (fibonaciSequence 10))
|
putStrLn ("FionacciList 10 " ++ show (fibonnaciSequence 10))
|
||||||
|
|
||||||
testProblems:: IO()
|
testProblems:: IO()
|
||||||
testProblems = do
|
testProblems = do
|
||||||
@ -138,14 +137,14 @@ fizzBuzz (x:xs) = isFizzBuzz x : fizzBuzz xs
|
|||||||
| mod x 3 == 0 = "Fizz"
|
| mod x 3 == 0 = "Fizz"
|
||||||
| otherwise = show x
|
| otherwise = show x
|
||||||
|
|
||||||
-- Fibonacci number at indice n
|
-- Fibonnaci number at indice n
|
||||||
fibonacci :: Int -> Int
|
fibonacci :: Int -> Int
|
||||||
fibonacci 0 = 0
|
fibonacci 0 = 0
|
||||||
fibonacci 1 = 1
|
fibonacci 1 = 1
|
||||||
fibonacci n = fibonacci (n - 1) + fibonacci (n - 2)
|
fibonacci n = fibonacci (n - 1) + fibonacci (n - 2)
|
||||||
|
|
||||||
-- Fibonaci sequence until indice n
|
-- Fibonnaci sequence until indice n
|
||||||
fibonaciSequence :: Int -> [Int]
|
fibonnaciSequence :: Int -> [Int]
|
||||||
fibonaciSequence 0 = [0]
|
fibonnaciSequence 0 = [0]
|
||||||
fibonaciSequence 1 = [0, 1]
|
fibonnaciSequence 1 = [0, 1]
|
||||||
fibonaciSequence n = fibonaciSequence (n - 1) ++ [fibonacci n]
|
fibonnaciSequence n = fibonnaciSequence (n - 1) ++ [fibonacci n]
|
15
Makefile
Normal file
15
Makefile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
.PHONY: all Main debug start clean
|
||||||
|
|
||||||
|
all: Main
|
||||||
|
|
||||||
|
Main: Main.hs
|
||||||
|
@ghc -Wno-tabs Main.hs
|
||||||
|
|
||||||
|
start: Main
|
||||||
|
@./Main
|
||||||
|
|
||||||
|
debug: Main.hs
|
||||||
|
@ghc -Wno-tabs -keep-hc-files -keep-tmp-files $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm *.hi Main *.o || true
|
@ -1,11 +1,11 @@
|
|||||||
--module Primes ( aspGetNextPrime, aspIsPrime, aspPrimes ) where
|
module Primes ( aspGetNextPrime, aspIsPrime, aspPrimes ) where
|
||||||
module Primes ( aspGetNextPrime, aspIsPrime ) where
|
|
||||||
import Problems ( kth )
|
import Problems ( kth )
|
||||||
|
|
||||||
aspGetNextPrime :: Int -> Int
|
aspGetNextPrime :: Int -> Int
|
||||||
aspGetNextPrime 1 = 2
|
aspGetNextPrime 1 = 2
|
||||||
aspGetNextPrime 2 = 3
|
aspGetNextPrime 2 = 3
|
||||||
aspGetNextPrime n = aspGetNextPrime (n + 2)
|
aspGetNextPrime n
|
||||||
|
| otherwise = aspGetNextPrime (n + 2)
|
||||||
|
|
||||||
aspIsPrime :: Int -> Bool
|
aspIsPrime :: Int -> Bool
|
||||||
aspIsPrime 1 = False
|
aspIsPrime 1 = False
|
||||||
@ -17,5 +17,5 @@ aspIsPrime n = mod n (aspGetNextPrime 1) == 0
|
|||||||
--aspPrimeFactors 1 = [1]
|
--aspPrimeFactors 1 = [1]
|
||||||
|
|
||||||
--aspPrimes :: (Integral Int) => [Int]
|
--aspPrimes :: (Integral Int) => [Int]
|
||||||
--aspPrimes = sieve [2..]
|
aspPrimes = sieve [2..]
|
||||||
-- where sieve (x:xs) = [ x | x <- xs, x mod p == 0]
|
where sieve (x:xs) = [ x | x <- xs, x mod p == 0]
|
@ -1,7 +0,0 @@
|
|||||||
services:
|
|
||||||
haskell-playground:
|
|
||||||
image: saundersp/haskell-playground
|
|
||||||
pull_policy: never
|
|
||||||
build: .
|
|
||||||
volumes:
|
|
||||||
- ./:/home/saundersp/haskell_playground
|
|
@ -1,16 +0,0 @@
|
|||||||
cabal-version: 2.4
|
|
||||||
name: haskell-playground
|
|
||||||
version: 0.1.0.0
|
|
||||||
author: saundersp
|
|
||||||
maintainer: pierre.saundersgb@gmail.com
|
|
||||||
|
|
||||||
executable haskell-playground
|
|
||||||
main-is: Main.hs
|
|
||||||
build-depends:
|
|
||||||
primes,
|
|
||||||
base ^>=4.16.4.0
|
|
||||||
other-modules:
|
|
||||||
Primes
|
|
||||||
Problems
|
|
||||||
hs-source-dirs: app
|
|
||||||
default-language: Haskell2010
|
|
Loading…
x
Reference in New Issue
Block a user