S++Core systems, human-reviewable
DEMO SOURCE · SPP / APP / PHYRead the book

petshop-40-queries.spp

petshop/catalogue/petshop-40-queries.spp

Download original file · Petstore source contents

1domain petshop;23Scenario serial readShopInventory(Goods, Goods[], StockLine[]) {4    prepareProductSelection;5    listProducts;6    prepareInventorySelection;7    findStockLine;8    identify(stockLines);9}1011Scenario serial readShopMerchant(Merchant) {12    configureMerchantLookup;13    findMerchant;14    identify(merchant);15}1617atomic calculate prepareProductSelection(Goods) {18    goods.active = true;19}2021atomic calculate filterProducts(Goods, Goods[]) {22    Goods[] filtered = new Goods[] {23    };24    for (Goods product : goodss) {25        if (goods.category == BLANK || product.category == goods.category) {26            filtered = append(filtered, product);27        }28    }29    goodss = filtered;30}3132Scenario serial browseShopProducts(Goods, Goods[]) {33    prepareProductSelection;34    listProducts;35    localizeCatalog;36    filterProducts;37}