5data RLE : Vect n Char -> Type where
7 RChar : {xs : Vect k Char} ->
8 (n : Nat) -> (c : Char) -> (rs : RLE xs) ->
9 RLE (replicate (S n) c ++ xs)
13rle : (xs : Vect n Char) -> RLE xs
15rle (x :: xs) with (rle xs)
16 rle (x :: []) | REnd = RChar 0 x REnd
17 rle (x :: (c :: (replicate n c ++ ys))) | (RChar n c rs) with (decEq x c)
18 rle (x :: (x :: (replicate n x ++ ys))) | (RChar n x rs) | (Yes Refl)
20 rle (x :: (c :: (replicate n c ++ ys))) | (RChar n c rs) | (No f)
21 = RChar 0 x (RChar n c rs)
23compress : Vect n Char -> String
24compress xs with (rle xs)
25 compress [] | REnd = ""
26 compress (c :: (replicate n c ++ xs1)) | (RChar n c rs)
27 = show (the Integer (cast (S n))) ++
28 strCons c (compress xs1)
30compressString : String -> String
31compressString xs = compress (fromList (unpack xs))
34main = 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