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