helper-example.sleela
lib/advantage/examples/medium/supply-chains/helper-example.sleela · 88 line(s) · sleela
<< lib/advantage/examples/medium/supply-chains/helper-example.sleela
SLeeLa Standard Library Definition.
Definition: A professional example -- the HELPER -- stands up a small
supply->retail chain and moves goods through it (vertical integration). >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
<< A helper distributes and supports: they assemble a vertical-integration
chain (advantage/integration) from upstream supply to downstream storefront
and push goods through it. Tiers: supply (resource) -> bay (engineering) ->
store (selling). Store 8 units at supply, flow one hop downstream: 8 units
land in the bay. The chain has 3 tiers and 3 compartments. Names
SLVerticalIntegration / SLCompartment, resolved from lib/advantage/integration/. >>
class HelperExample {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Baseline identity record for a worker-class example. >>
String metaVersion = "1.0.0";
int metaId = 10573;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-11-08";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-11-08";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 8;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
void main() {
print("== professional: the Helper ==");
SLVerticalIntegration vi = new SLVerticalIntegration();
vi.configure("relief-chain");
< kind 5 = resource (supply), 2 = engineering-bay, 14 = selling (store) >
SLCompartment supply = vi.addKind("supply", 5);
SLCompartment bay = vi.addKind("depot", 2);
SLCompartment store = vi.addKind("storefront", 14);
print(" tiers built = " + vi.getTierCount());
print(" compartments = " + vi.totalCompartments());
supply.store(8);
int moved = vi.flowDownstream(0, 8);
print(" stored 8 at supply, flowed downstream = " + moved);
print(" supply used = " + supply.getUsed() + ", depot used = " + bay.getUsed());
print("");
print("== validation ==");
boolean okTiers = (vi.getTierCount() == 3);
boolean okComp = (vi.totalCompartments() == 3);
boolean okMoved = (moved == 8);
boolean okFlow = (supply.getUsed() == 0) && (bay.getUsed() == 8);
print(" 3 tiers ? " + okTiers);
print(" 3 compartments ? " + okComp);
print(" moved 8 downstream ? " + okMoved);
print(" supply emptied ? " + okFlow);
if (okTiers) { if (okComp) { if (okMoved) { if (okFlow) {
print("ALL CHECKS PASSED");
} } } }
}
}