Jill starts to order some coffee. She adds a small, dark roast. Then she adds a large medium roast with double almond syrup. She adds a medium medium roast with two soy shots (the second one by accident). She reads the price and it's too expensive. So she removes the second coffee (the one with the almond syrup). Then she realizes the third coffee has two soy shots and she removes one. The price looks good, so she submits the order.
Last active
October 9, 2025 01:50
-
-
Save ericnormand/ba6a1bb9456ee8b6b932fbddfeb3ad47 to your computer and use it in GitHub Desktop.
Coffee Shop Scenario
djwhitt
commented
Oct 9, 2025
;; cup
;; roast - enumeration
;; size - enumeration
;; flavors - flavor -> quantity
{:cup1 {:size :m
:roast :d
:flavors {:almond 2
:soy 1}}
:cup2 {:size :m}}
(defn price [order])
(defn <alter-order> [order item])
(defn submit [order])[:create-order :order1]
[:create-coffee :order1 :coffee1]
[:set-roast :order1 :coffee1 :dark]
[:set-size :order1 :coffee1 :small]
[:create-coffee :order1 :coffee2]
[:set-size :order1 :coffee2 :large]
[:set-roast :order1 :coffee2 :medium]
[:add-extra :order1 :coffee2 :almond]
[:add-extra :order1 :coffee2 :almond]
[:create-coffee :order1 :coffee3]
[:set-size :order1 :coffee3 :medium]
[:set-roast :order1 :coffee3 :medium]
[:add-extra :order1 :coffee3 :soy]
[:add-extra :order1 :coffee3 :soy]
[:calc-price :order1]
[:remove-coffee :order1 :coffee2]
[:remove-extra :order1 :coffee3 :soy]
[:calc-price :order1]
[:submit :order1](let [o (create-order)
c1 (create-coffee :small :dark)
o (add-coffee o c1)
c2 (create-coffee :large :medium)
c2 (add-add-in c2 [:almond 2])
o (add-coffee o c2)]
o)Claude's take:
(let [o (create-order)
c1 (create-coffee :small :dark)
o (add-coffee o c1)
c2 (create-coffee :large :medium)
c2 (add-add-in c2 [:almond 2])
o (add-coffee o c2)
;; Add medium medium roast with two soy shots
c3 (create-coffee :medium :medium)
c3 (add-add-in c3 [:soy 1])
c3 (add-add-in c3 [:soy 1]) ;; second one by accident
o (add-coffee o c3)
;; Price is too expensive, remove the almond syrup coffee (c2)
o (remove-coffee o c2)
;; Remove one soy shot from c3
c3 (remove-add-in c3 [:soy 1])
o (update-coffee o c3)
;; Submit the order
o (submit-order o)]
o)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment