Skip to content

Instantly share code, notes, and snippets.

Avatar
🍓
playing celeste

Chris Parks cdparks

🍓
playing celeste
View GitHub Profile
@cdparks
cdparks / gist:f18373921c7a59156cd7
Created Mar 21, 2015
Partially initialized record
View gist:f18373921c7a59156cd7
data Point2D = Point2D { x :: Double, y :: Double }
p = Point2D { x = 1 }
-- Point2D (D# 1.0) (recConError "x.hs:3:5-21|y"#)
main = do
print (x p)
print (y p) -- BOOM
@cdparks
cdparks / Stream.hs
Created Feb 25, 2015
Lazy infinite streams in Haskell, Swift, and Python
View Stream.hs
module Main where
import Prelude hiding (
iterate, repeat, map, filter, zipWith, zip,
take, takeWhile, drop, dropWhile)
import qualified Prelude as P
import Text.Printf (printf)
import Data.List (intercalate)
infixr 5 :>
View Shaden.hs
import Data.Char (ord)
main = print $ rot13 "unccl oveguqnl, funqra!"
where
rot13 = foldr replace []
alpha = ['a'..'z']
index x = (ord x - ord 'a' + 13) `mod` 26
replace x xs
| x `elem` alpha = alpha !! index x:xs
| otherwise = x:xs
You can’t perform that action at this time.