-O3
but not -O0
-Wall -Wextra
-Wall -Wextra
gdb
./build.sh -O0
ret
instruction.
is the function composition operatorflip13
is a function that swaps the 1st and 3rd arguments of a function
applyTwice
basically works like this applyTwice(f, x) = f(f(x))
and twiceApply
is that but kinda backwards, so twiceApply(f, x) = (f(x))(x)
updateIndex
does
Here's the Python implementation
def updateIndex(l, i, x):
new_l = l.copy()
new_l[i] = x
return new_l
updateIndex = curry $ liftM2 (flip13 $ compose2 (flip (++)) (:)) (uncurry $ flip take) (uncurry $ flip $ drop . succ)
updateIndex2 = curry $ liftM2 (.) (liftM2 updateIndex fst (snd . snd)) (liftM2 updateIndex (liftM2 (!!) fst (snd . snd)) (fst . snd))
This one is very convenient, it uses updateIndex
twice to update a value in a two-dimensional listupdateIndex
one word at a time
curry
turns f((a, b))
into f(a, b)
liftM2
can do a ton of things which don't necessarily even make sense in other languages, but in this case it's basically liftM2(f, g, h, x) = f(g(x), h(x))
flip13
is basically flip13(f, a, b, c) = f(c, b, a)
compose2
is basically compose2(f, g, a, b) = f(g(a, b))
ugh I'm getting tired
uncurry
is the reverse of curry
, turns f(a, b)
into f((a, b))
(1 +)
is a function that adds 1 to whatever value you give itIO ()
that value represents the IO that your application performs
so to modify a file your program has to return a value that represents a file modification