Skip to content

Conversation

@dckc
Copy link
Contributor

@dckc dckc commented Jan 10, 2025

refs:

The counter example runs; I'm writing ($ rx m args ...) instead of (rx .m args ...)

($ console log "\nTesting counter with offset:")
(module
  (define make-counter
    (fn (init)
      (var value init)
      (return (%r
               (: increment (fn () (+= value 1)))
               (: decrement (fn () (-= value 1)))
               (: makeOffsetCounter
                  (fn (delta)
                    (return (make-counter (+ value delta)))))))))
  (define c1 (make-counter 5))
  ($ console log "Initial counter at 5")
  ($ c1 increment)
  ($ console log "After increment:" ($ c1 decrement))
  (define c2 ($ c1 makeOffsetCounter 10))
  ($ console log "New counter with +10 offset")
  ($ c2 increment)
  ($ console log "After increment:" ($ c2 decrement)))

output:

Testing counter with offset:
Initial counter at 5
After increment: 5
New counter with +10 offset
After increment: 15

full disclosure: my scheme-fu is weak, so I leaned on aider with --sonnet for most of the details.
The git log shows which parts it wrote and which parts I did by hand.

IOU the chat log. It might serve as an interesting record of somebody learning scheme.

dckc added 30 commits January 9, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant