~zainab/blog

ed1b0b9ccbb83c05fd3849102e2549d3e8900dbf — zainab-ali 6 months ago 04df756 2023-06-25-infinity-in-the-palm-of-your-hand
Content: Split out diagrams.
1 files changed, 21 insertions(+), 24 deletions(-)

M src/pull-model/diagrams.rkt
M src/pull-model/diagrams.rkt => src/pull-model/diagrams.rkt +21 -24
@@ 53,11 53,11 @@
      (pull take upstream)
      (done upstream take)
      (done take downstream))
     #:title "upstream is done"))
  (vc-append take-value take-too-many take-not-enough)
     ))
  take-not-enough
  )

(define (repeat-op-diagram)
(define (repeat-op-diagram-base)
  (define upstream "upstream")
  (define repeat "repeat")
  (define downstream "downstream")


@@ 68,8 68,14 @@
     (list (pull downstream repeat)
           (pull repeat upstream)
           (output upstream repeat "value")
           (output repeat downstream "value"))
     #:title "upstream outputs a value"))
           (output repeat downstream "value"))))
  repeat-value)

(define (repeat-op-diagram-done)
  (define upstream "upstream")
  (define repeat "repeat")
  (define downstream "downstream")
  (define operators (list upstream repeat downstream))
  (define repeat-done
    (make-diagram
     operators


@@ 79,35 85,24 @@
           (pull repeat upstream)
           (output upstream repeat "first value")
           (output repeat downstream "first value"))
     #:title "upstream is done"))
  (ht-append repeat-value repeat-done))
     ))
  repeat-done)

(define (base-op-diagram)
  (define base "Stream(\"Mao\", \"Popcorn\")")
  (define downstream "downstream")
  (define operators (list base downstream))
  (define first-pull
  (define base-diagram
    (make-diagram
     operators
     (list
      (pull downstream base)
      (output base downstream "\"Mao\""))
     #:title "1st pull"))
  (define second-pull
    (make-diagram
     operators
     (list
      (output base downstream "\"Mao\"")
      (pull downstream base)
      (output base downstream "\"Popcorn\""))
     #:title "2nd pull"))
  (define third-pull
    (make-diagram
     operators
     (list
      (output base downstream "\"Popcorn\"")
      (pull downstream base)
      (done base downstream))
     #:title "3rd pull"))
  (ht-append first-pull second-pull third-pull))
      (done base downstream))))
  base-diagram)

(define (composition)
  (define last ".compile.last")


@@ 150,6 145,8 @@
(define base-path "../assets/images/2023-06-25-fs2-infinity/")
(pict->svg (take-concrete-diagram) #:output (string-append base-path "pull-model-take-concrete.svg"))
(pict->svg (take-op-diagram) #:output (string-append base-path "pull-model-take.svg"))
(pict->svg (repeat-op-diagram) #:output (string-append base-path "pull-model-repeat.svg"))
(pict->svg (repeat-op-diagram-base) #:output (string-append base-path "pull-model-repeat-base.svg"))
(pict->svg (repeat-op-diagram-done) #:output (string-append base-path "pull-model-repeat-done.svg"))
(pict->svg (base-op-diagram) #:output (string-append base-path "pull-model-stream-apply.svg"))
(pict->svg (composition) #:output (string-append base-path "pull-model-composition.svg"))