(home)

📝
purely functional data structures notes


  • see 👤 Dan Luu's warning: danluu.com/programming-books
  • p7
  • p15
  • p34
    • uses stream as the name of lazy lists
  • queue progression
    • Note: there's also queue code in Haskell in the back of the book on p186
    • p42
      • interface excerpt:
      signature Queue =
      sig
        type a Queue
      
      val empty   : a Queue
      val isEmpty : a Queue -> bool
      
      val snoc    : a Queue × a -> a Queue
      val head    : a Queue -> a       (* raises Empty if queue is empty *)
      val tail    : a Queue -> a Queue (* raises Empty if queue is empty *)
      • BatchedQueue/pair of lists implementation excerpt:
      type a Queue = a list × a list
    • p64
      • BankerQueue implementation excerpt:
      type a Queue = int × a Stream × int × a Stream
    • p72
      • PhysicistsQueue implementation excerpt:
      type a Queue = a list × int × a list susp × int × a list
    • 86
      • real-time queues
        • all operations in O(1) worst-case time
        • need to rotate incrementally
      • implementation excerpt:
      type a Queue = a Stream × a list × a Stream
    • 102
      • Hood-Melville real-time queues
        • more complex than the previous implementation
        • what's the advantage? better constant times? #question
      • implementation excerpt:
      datatype a RotationState =
            Idle
          | Reversing of int × a list × a list × a list × a list
          | Appending of int × a list × a list
          | Done of a list
      
      type a Queue = int × a list × a RotationState × int × a list