Skip to content

Commit

Permalink
Cleanup unused pattern variable, implement car deforestation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzoep committed Nov 11, 2023
1 parent bb59629 commit 6531cb5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions qi-lib/flow/core/deforest.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
(define-syntax-class fusable-stream-producer
#:attributes (next prepare)
#:datum-literals (#%host-expression #%partial-application esc)
(pattern (~and (esc (#%host-expression (~literal range)))
stx)
(pattern (esc (#%host-expression (~literal range)))
#:attr next #'range->cstream-next
#:attr prepare #'range->cstream-prepare)
(pattern (~and (#%partial-application
Expand Down Expand Up @@ -111,7 +110,9 @@
#:when (and chirality (eq? chirality 'right))
#:attr end #'(foldl-cstream-next op init))
(pattern (~literal cstream->list)
#:attr end #'(cstream-next->list)))
#:attr end #'(cstream-next->list))
(pattern (esc (#%host-expression (~literal car)))
#:attr end #'(car-cstream-next)))

(define-syntax-class non-fusable
(pattern (~not (~or _:fusable-stream-transformer
Expand Down Expand Up @@ -246,3 +247,11 @@
(λ (value state)
(loop (op value acc) state)))
state))))

(define-inline (car-cstream-next next)
(λ (state)
(let loop ([state state])
((next (λ () (error 'car "Empty list!"))
(λ (state) (loop state))
(λ (value state)
value))))))

0 comments on commit 6531cb5

Please sign in to comment.