|
|
|
|
|
by kazinator
3425 days ago
|
|
Here is a version of basket add-to with a recursive local function for doing the insert, avoiding the clumsy mapcar and "did we insert or not" check copied from the F# code. (defmeth basket add-to (me product quantity)
(labels ((insert (lines)
(tree-case lines
((line . rest) (if (equal line.product-sku product.sku)
(cons (build-line product
(+ line.quantity quantity))
rest)
(cons line (insert rest))))
(() (list (build-line product quantity))))))
(new basket lines (insert me.lines))))
|
|