D11_Colors.sleela
tutorial/demos/src/D11_Colors.sleela · 27 line(s) · sleela
#sleela 2.1
// D11_Colors.sleela — companion to Lesson 11 (HTTP 3.0 & HTTP colors).
// Models the "name a color -> get a profile" idea in plain SLeeLa: a color name
// maps to a small integer strictness level (green<amber<red<black). The real
// palette + wire behavior live in http-3.0/ (http3_profile.*, HTTP-COLORS.md).
class D11_Colors {
// green=0, amber=1, red=2, black=3 ; -1 for an unknown color.
int strictness(String color) {
if (color == "green") { return 0; }
if (color == "amber") { return 1; }
if (color == "red") { return 2; }
if (color == "black") { return 3; }
return -1;
}
void main() {
print("== Lesson 11: HTTP colors ==");
print("green -> " + strictness("green"));
print("amber -> " + strictness("amber"));
print("red -> " + strictness("red"));
print("black -> " + strictness("black"));
print("orders would use color red (full integrity + basket)");
print("done");
}
}