Zipping Lists with Repetition -- a puzzle Koen Lindstrm Claessen - - PowerPoint PPT Presentation

zipping lists with repetition a puzzle
SMART_READER_LITE
LIVE PREVIEW

Zipping Lists with Repetition -- a puzzle Koen Lindstrm Claessen - - PowerPoint PPT Presentation

Zipping Lists with Repetition -- a puzzle Koen Lindstrm Claessen type Nat = Int data List a = Unit a | List a :++: List a | Rep Nat (List a) same length zip :: List a -> List a -> List (a,b) minimal size len :: List a -> Integer


slide-1
SLIDE 1

Zipping Lists with Repetition

  • - a puzzle

Koen Lindström Claessen

slide-2
SLIDE 2

zip :: List a -> List a -> List (a,b) data List a = Unit a | List a :++: List a | Rep Nat (List a)

same length minimal size

type Nat = Int

slide-3
SLIDE 3

len :: List a -> Integer len (Unit x) = 1 len (p :++: q) = len p + len q len (Rep n p) = n * len p size :: List a -> Integer size (Unit x) = 1 size (p :++: q) = size p + size q size (Rep _ p) = size p

slide-4
SLIDE 4

zip :: List a -> List a -> List (a,b)

polynomial in the size

  • f the result (?)

best heuristic independent of the number of repetitions

slide-5
SLIDE 5

type List a = [Node a] data Node a = Unit a | Rep Nat (List a) https://github.com/koengit/zippuzzle