9rep : (n : Nat) -> Char -> Vect n Char
11rep (S k) x = x :: rep k x
13data RLE : Vect n Char -> Type where
20 -> RLE (rep (S n) x ++ xs)
22eq : (x : Char) -> (y : Char) -> Maybe (x = y)
23eq x y = if x == y then Just (believe_me (Refl {x})) else Nothing
27rle : (xs : Vect n Char) -> RLE xs
29rle (x :: xs) with (rle xs)
30 rle (x :: Vect.Nil) | REnd = RChar Z x REnd
31 rle (x :: rep (S n) yvar ++ ys) | RChar n yvar rs with (eq x yvar)
32 rle (x :: rep (S n) x ++ ys) | RChar n x rs | Just Refl
34 rle (x :: rep (S n) y ++ ys) | RChar n y rs | Nothing
35 = RChar Z x (RChar n y rs)
37compress : Vect n Char -> String
38compress xs with (rle xs)
39 compress Nil | REnd = ""
40 compress (rep (S n) x ++ xs) | RChar _ _ rs
41 = let ni : Integer = cast (S n) in
42 show ni ++ strCons x (compress xs)
45fmt : {xs : Vect n Char} -> RLE xs -> String
47fmt (RChar n c xs) = show n ++ show c ++ fmt xs
50compressString : String -> String
51compressString xs = compress (fromList (unpack xs))
54main = putStrLn (compressString "foooobaaaarbaaaz")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list