Update examples

This commit is contained in:
apio 2022-08-25 10:01:14 +02:00
parent d341e90237
commit d0c219e839
7 changed files with 28 additions and 29 deletions

View File

@ -1,5 +1,5 @@
import core/flow; const { exit } from @'core/os';
@main { let @main in {
flow.exit(1); exit(1);
} }

View File

@ -1,10 +1,10 @@
import core/io; const io from @'core/io';
import core/fs; const { open } from @'core/fs';
@main { let @main in {
io.out('What\'s your name? '); io.out("What is your name? ");
str name = io.in(); let name = io.in();
fs.File nameFile = fs.open('name.txt'); let file = open("name.txt");
nameFile.write(name); file.write(name);
nameFile.close(); file.close();
} }

View File

@ -1,8 +1,9 @@
import core/io; const io from @'core/io';
import core/string; const { concat } from @'core/string';
const { toString } from @'core/float_utils';
@main { let @main in {
f128 float1 = 234.6; let float1 : f128 = 234.6;
f128 float2 = 2934748348291930404.5; f128 float2 : f128 = 2934748348291930404.5;
io.outln(string.concat('Result is: ',(str)(float1 + float2))); io.outln(concat('Result is: ',toString(float1 + float2)));
} }

View File

@ -1,5 +1,5 @@
import core/io; const io from @'core/io';
@main { let @main in {
io.outln('Hello world!'); io.outln('Hello world!');
} }

View File

@ -1,8 +1,8 @@
import core/io; const io from @'core/io';
@main { let @main in {
io.out('What\'s your name? '); io.out('What\'s your name? ');
str name = io.in(); let name = io.in();
io.out('Hello, '); io.out('Hello, ');
io.out(name); io.out(name);
io.out('!!'); io.out('!!');

View File

@ -1,12 +1,10 @@
let { io } in @'core/io'; const { io } from @'core/io';
let good_food : String = 'watermelon'; const good_food : String = 'watermelon';
let @main : i32 in { let @main in {
io.outln('Hello world!'); io.outln('Hello world!');
io.outf('My favorite food is %s\n',good_food); io.outf('My favorite food is %s\n',good_food);
return 0;
} }

View File

@ -1,7 +1,7 @@
import core/io; const io from @'core/io';
@main { @main {
i32 age = 64; let age : i32 = 64;
io.out('I am '); io.out('I am ');
io.out(age); io.out(age);
io.outln(' years old.'); io.outln(' years old.');