Skip to content

Instantly share code, notes, and snippets.

Bit Wombat bitwombat

  • NSW, Australia
Block or report user

Report or block bitwombat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:b97497bd8dd9b2d2ad7ed6466140d880
cups:
Installed: (none)
Candidate: 2.2.7-1ubuntu2
Version table:
2.2.7-1ubuntu2 500
500 http://au.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
@bitwombat
bitwombat / Spec.hs
Created Jul 25, 2019
Page 562 exercises
View Spec.hs
module Page562Tests where
import Page562
import Test.QuickCheck
import Data.List (sort)
--Ex 1
halfIdentity :: (Fractional a, Num a) => a -> a
halfIdentity = (*2) . half
@bitwombat
bitwombat / Spec.hs
Created Jul 25, 2019
Page 562 exercises
View Spec.hs
module Page562Tests where
import Page562
import Test.QuickCheck
import Data.List (sort)
--Ex 1
halfIdentity :: (Fractional a, Num a) => a -> a
halfIdentity = (*2) . half
@bitwombat
bitwombat / letter_freq.py
Last active Jul 23, 2019
Calculate the frequency of letters, via generic Python
View letter_freq.py
'''Character counting as a fold'''
from functools import reduce
from itertools import repeat
from os.path import expanduser
# charCounts :: String -> Dict Char Int
def charCounts(s):
'''A dictionary of
View Page475_trimmed.hs
module Page475 where
-- Ex 5
either' :: (a -> c) -> (b -> c) -> Either a b -> c
either' f g eab =
case eab of
Left a -> f a
Right b -> g b
-- Ex 6
@bitwombat
bitwombat / Page475.hs
Created Jul 19, 2019
HPFFP Exercise page 475
View Page475.hs
module Page475 where
f :: Either a b -> [a] -> [a]
f c d = case c of
Left x -> d ++ [x]
_ -> d
lefts' :: [Either a b] -> [a]
lefts' e = foldr (f) [] e
@bitwombat
bitwombat / Page447.hs
Created Jul 16, 2019
Ex 2 on Page 447
View Page447.hs
module Page447 where
import Data.Char
capitalizeWord :: String -> String
capitalizeWord (c:cs) = toUpper c : cs
endsWithPeriod :: String -> Bool
endsWithPeriod word = last word == '.'
@bitwombat
bitwombat / Page442.hs
Created Jul 15, 2019
Solutions to Page442 exercise of HPFFP
View Page442.hs
module Page442 where
data BinaryTree a =
Leaf
| Node (BinaryTree a) a (BinaryTree a)
deriving (Eq, Ord, Show)
preorder :: BinaryTree a -> [a]
preorder Leaf = []
preorder (Node left val right) = [val] ++ (preorder left) ++ (preorder right)
@bitwombat
bitwombat / Page440.hs
Created Jul 15, 2019
Page440 solution to exercise in HPFFP
View Page440.hs
module Page440 where
data BinaryTree a =
Leaf
| Node (BinaryTree a) a (BinaryTree a)
deriving (Eq, Ord, Show)
mapTree :: (a -> b)
-> BinaryTree a
-> BinaryTree b
@bitwombat
bitwombat / Page440.hs
Created Jul 14, 2019
mapTree exercise, page 440.
View Page440.hs
module Page440 where
data BinaryTree a =
Leaf
| Node (BinaryTree a) a (BinaryTree a)
deriving (Eq, Ord, Show)
mapTree :: (a -> b)
-> BinaryTree a
-> BinaryTree b
You can’t perform that action at this time.