Skip to content

Instantly share code, notes, and snippets.

@ppetr
Created August 11, 2015 06:21
Show Gist options
  • Save ppetr/5fe182116ee22445545d to your computer and use it in GitHub Desktop.
Save ppetr/5fe182116ee22445545d to your computer and use it in GitHub Desktop.
Building a recursive lazy pure FIFO
Empty
FIFO [0] Empty 1 [] 0
FIFO [0] Empty 1 [1] 1
FIFO [0] (FIFO [[1,2]] Empty 1 [] 0) 3 [] 0
FIFO [0] (FIFO [[1,2]] Empty 1 [] 0) 3 [3] 1
FIFO [0] (FIFO [[1,2]] Empty 1 [] 0) 3 [4,3] 2
FIFO [0] (FIFO [[1,2]] Empty 1 [] 0) 3 [5,4,3] 3
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [] 0
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [7] 1
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [8,7] 2
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [9,8,7] 3
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [10,9,8,7] 4
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [11,10,9,8,7] 5
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [12,11,10,9,8,7] 6
FIFO [0] (FIFO [[1,2]] Empty 1 [[3,4,5,6]] 1) 7 [13,12,11,10,9,8,7] 7
FIFO [0] (FIFO [[1,2]] (FIFO [[[3,4,5,6],[7,8,9,10,11,12,13,14]]] Empty 1 [] 0) 3 [] 0) 15 [] 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment