Got an exam Wednesday that lumi should study for since it failed that class.
Uncategorized
2
Posts
2
Posters
6
Views
-
Got an exam Wednesday that lumi should study for since it failed that class. Instead, been learning Koka
// +, 0, - -> 1, 0, -1 fun unfoldr(f : b -> maybe2, init : b) : div list match f(init) Just2(a, b) -> Cons(a, unfoldr(f, b)) Nothing2 -> Nil fun map-if(xs : list, f : a -> a, b : bool) : list if b then xs.map(f) else xs fun neg-trit(trit : char) : char match trit '+' -> '-' '-' -> '+' e -> e fun bal-tri(x : int) : div list unfoldr(fn(n) if n != 0 then match n % 3 0 -> Just2('0', n / 3) 1 -> Just2('+', n / 3) _ -> Just2('-', n / 3 + 1) else Nothing2 , x.abs).map-if(neg-trit, x.is-neg()).reverse()-9.bal-tri().string()-00
25.bal-tri().string()+0-+
-
Got an exam Wednesday that lumi should study for since it failed that class. Instead, been learning Koka
// +, 0, - -> 1, 0, -1 fun unfoldr(f : b -> maybe2, init : b) : div list match f(init) Just2(a, b) -> Cons(a, unfoldr(f, b)) Nothing2 -> Nil fun map-if(xs : list, f : a -> a, b : bool) : list if b then xs.map(f) else xs fun neg-trit(trit : char) : char match trit '+' -> '-' '-' -> '+' e -> e fun bal-tri(x : int) : div list unfoldr(fn(n) if n != 0 then match n % 3 0 -> Just2('0', n / 3) 1 -> Just2('+', n / 3) _ -> Just2('-', n / 3 + 1) else Nothing2 , x.abs).map-if(neg-trit, x.is-neg()).reverse()-9.bal-tri().string()-00
25.bal-tri().string()+0-+
@lumi study for it smh, you can do it
-
R ActivityRelay shared this topic