Skip to content

Instantly share code, notes, and snippets.

View jc99kuo's full-sized avatar

Johntim J.C. Kuo jc99kuo

View GitHub Profile
@jc99kuo
jc99kuo / prerequisites.hs
Created June 12, 2018 09:48
Prerequisites in FLOLAC 2018
-- Answers for Prerequisites in FLOLAC 2018
-- 1) myFst
myFst :: (a, b) -> a
myFst (x, _) = x
-- 2) myOdd
myOdd :: Int -> Bool
@jc99kuo
jc99kuo / caesarCipher.hs
Created May 22, 2018 16:04
FLOLAC 2018 Week 4 (2018-5-21 19:17) -- Caesar Cipher & Decipher
-- 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
@jc99kuo
jc99kuo / goldbach.hs
Created May 11, 2018 15:57
FLOLAC 2018 Week 3 (2018-5-11 11:46) -- Goldbach's Conjecture
-- 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
@jc99kuo
jc99kuo / histogram.hs
Created May 3, 2018 16:26
FLOLAC 2018 Week 1 (2018-5-03 16:20) -- Histogram
-- 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"
@jc99kuo
jc99kuo / nub.hs
Created April 26, 2018 08:53
FLOLAC 2018 Week 1 (2018-4-25 14:14) -- nub: filter out duplicating integers on a list
-- 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) ->