Skip to content

Instantly share code, notes, and snippets.

@stanch
Created October 6, 2016 23:33
Show Gist options
  • Save stanch/593f9c241a6bf8e676d324ac9a6d7f4e to your computer and use it in GitHub Desktop.
Save stanch/593f9c241a6bf8e676d324ac9a6d7f4e to your computer and use it in GitHub Desktop.
// git clone https://github.com/stanch/reftree && cd reftree
// sbt demo
def add(n: Int)(q: Queue[Int]) = Utils.iterate(q, n + 1)(q => q :+ (q.max + 1)).tail
def remove(n: Int)(q: Queue[Int]) = Utils.iterate(q, n + 1)(q => q.tail).tail
def addRemove(n: Int)(q: Queue[Int]) = Utils.flatIterate(q)(add(n), rm(n))
val queues = Utils.flatIterate(Queue(1, 2, 3), 3)(addRemove(2))
diagram.renderAnimation(
"queue", _.copy(
onionSkinLayers = 0, diffAccent = true, interpolationFrames = 21,
density = 100, delay = 200, silent = false
)
)(queues)
@stanch
Copy link
Author

stanch commented Oct 6, 2016

queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment