Output functions in Krypton
// Tutorial 08: Printing Output
// Output functions in Krypton
just run {
// print() adds a newline
print("Line one")
print("Line two")
// print() also prints with newline (shorthand)
print("Using print")
// Printing numbers
print("The answer: " + 42)
// Printing expressions
let x = 10
let y = 20
print("x=" + x + " y=" + y + " sum=" + (x + y))
// Multiple items via concatenation
print("Name: " + "Alice" + ", Age: " + 30)
// Print in a loop
let i = 1
while i <= 5 {
print(" Item #" + i)
i = i + 1
}
}
Click ▶ Run to execute. Lessons using k:fs/k:http/match/struct need the real runtime.
Tip: this code box is editable — tweak it, then hit Run, or copy into a .k file and run locally.
Run it locally: kcc -r tutorial/08_print.k