Skip to content

Instantly share code, notes, and snippets.

View thomwiggers's full-sized avatar

Thom Wiggers thomwiggers

View GitHub Profile
is_gelijk :: String String -> Bool
is_gelijk s1 s2
| size s1 == size s2 = is_gelijk_h s1 s2
= False
is_gelijk_h :: String String -> Bool
is_gelijk_h "" "" = True
is_gelijk_h s1 s2
| head s1 == head s2 = is_gelijk_h (tail s1) (tail s2)
= False
is_deel :: String String -> Bool
is_deel a b = size a <= size b && (is_gelijk a ""
||
head a == head b && is_deel (tail a) (tail b)
||
is_deel a (tail b)
)
is_gelijk :: String String -> Bool
is_gelijk a b
|not(size a == size b) = False
is_deelstring :: String String -> Bool
is_deelstring a b
|size a > size b = False
|size a == size b = a == b
foldr :: (a b -> b) b [a]
foldr op e [] = e
foldr op e (x:xs) = op x (foldr op e xs)
foldr op 0 [1,2] = op 1 (foldr op 0 [2])
= op 1 (op 2 (foldr op 0 []))
= op 1 (op 2 0)
@thomwiggers
thomwiggers / gist:7114534
Created October 23, 2013 08:13
v0 vs v9
thom@Lethe ~/Music/SortedMusic/Kavinsky - Outrun [2013] $ du -h *.mp3 01\ Pre<0301>lude.flac
3,3M v0.mp3
1,1M v9.mp3
13M 01 Prélude.flac
:: Type = Ding Int Int | GeenFiets
linkerkantvanding :: Type -> Int
linkerkantvanding (Ding a b) = a
linkerkantvanding GeenFiets = abort "MAGNIE"
iseending :: Type -> Bool
iseending (Ding _ _) = True
iseending _ = False
:: Expr = NR Int
// ...
instance toString Expr where
toString (NR a) = toString a
// ....
module test
import StdEnv
testfunctie :: Int -> (Int Int -> Int)
testfunctie 1 = (+)
Start = (testfunctie 1) 2 3 // output: 5
@thomwiggers
thomwiggers / ffoo.hs
Created October 25, 2013 22:07
LET ding
let_uitvoeren :: Naam Expr Expr -> Expr
let_uitvoeren naam e1 (VAR a)
| a == naam = e1
| otherwise = e2
let_uitvoeren naam e1 (OP e1 op e2) = -- hier iets recursiefs doen
-- enz
/*
I decided to add 3 hulp functions to solve this. I wanted to keep track of what values the children
should be smaller than and what values the children should be larger than. I did this by using 2 lists
one for smaller one for larger.
As such a child should either be smaller than certain parents and larger than certain parents. The lists
keep track of what values the child should be smaller / larger than.
A Leaf is always ordered, so is a node with no parents. Than there are 3 other cases:
Left & Right child is a node