Skip to content

Instantly share code, notes, and snippets.

@zesterer
Created October 26, 2019 10:59
Show Gist options
  • Save zesterer/0f67c86784abf154190b9654b00a86ce to your computer and use it in GitHub Desktop.
Save zesterer/0f67c86784abf154190b9654b00a86ce to your computer and use it in GitHub Desktop.
const std = struct {
io: struct {
print: |msg| {
__print(msg);
},
println: |msg| {
self.print(msg + "\n");
},
input: || {
__input()
},
ask: |msg| {
self.print(msg);
self.input()
},
},
iter: struct {
new: |next| {
struct {
next,
}
},
range: |start, end| self.new(|| if start == end {
null
} else {
let next = start;
start += 1;
next
}),
},
};
// Prelude
const input = std.io.input;
const ask = std.io.ask;
const print = std.io.print;
const println = std.io.println;
var name = ask("What is your name?");
println("Hello, " + name + "!");
for x in range(0, 10) {
println("{x}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment