While
While[condition, body]
Repeatedly evaluates body as long as condition evaluates to #t.
KSL does not provide break or continue statements; loop control is achieved by updating variables within the loop using Update.
- Returns
Unit[].
Let[i, 0];
While[Less[i, 3], Block[
Print[i],
Update[i, Add[i, 1]]
]];
Write
Write[path, append, content]
Writes the string content to the file at path.
appendis#tto append to an existing file, or#fto overwrite.- Returns
Unit[].
Write["log.txt", #f, Concat["First line", #10]];
Write["log.txt", #t, Concat["Second line", #10]];
WriteTerm
WriteTerm[s]
Writes the string s directly to the terminal, supporting ANSI escape sequences for cursor control and styling.
- Returns
Unit[].
WriteTerm["\x1b[H"]; (* Moves cursor to home position *)
WriteTerm["\x1b[2J"]; (* Clears the screen *)
Print["Hello, terminal!"];