This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Answers for Prerequisites in FLOLAC 2018 | |
-- 1) myFst | |
myFst :: (a, b) -> a | |
myFst (x, _) = x | |
-- 2) myOdd | |
myOdd :: Int -> Bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- FLOLAC 2018 Week 4 -- Caesar Cipher & Decipher | |
module CaesarCipher (encode, decode) where | |
import Data.List | |
letStart = 'A' | |
letFinal = 'Z' | |
letSeque = [letStart .. letFinal] | |
letQty = length letSeque |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- FLOLAC 2018 Week 3 -- Goldbach's conjecture | |
-- A simple, intuitive, straight fowward solution. | |
-- And may be not so efficient. :-) | |
goldbach :: Int -> Maybe (Int, Int) | |
goldbach nn | |
| nn < 3 = Nothing | |
| odd nn = Nothing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- FLOLAC 2018 Week 2 -- Histogram | |
histogram :: [Int] -> String | |
histogram ix = | |
concat [ row n | n <- [heigh, heigh - 1 .. 1]] ++ | |
"==========\n" ++ | |
"0123456789\n" | |
where | |
row m = [ if mm < m then ' ' else '*' | mm <- accl ] ++ "\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- FLOLAC 2018 Week 1 -- nub: filter out duplicating integers on a list | |
nub :: [Int] -> [Int] | |
nub ix = dedup [] ix | |
where | |
dedup = \xs ys -> | |
case ys of | |
[] -> xs | |
(yhead:ytail) -> |