aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/arguments.sloth9
-rw-r--r--examples/guessing.sloth3
-rw-r--r--examples/system.sloth5
3 files changed, 16 insertions, 1 deletions
diff --git a/examples/arguments.sloth b/examples/arguments.sloth
new file mode 100644
index 0000000..3e44dcc
--- /dev/null
+++ b/examples/arguments.sloth
@@ -0,0 +1,9 @@
+fn main(argc: Int, argv: [String]) Int {
+ if argc == 2 {
+ print("The argument supplied is ");
+ println(argv);
+ } else {
+ println("Wrong # of args");
+ }
+ return 0;
+}
diff --git a/examples/guessing.sloth b/examples/guessing.sloth
index 49c0bde..ef680c9 100644
--- a/examples/guessing.sloth
+++ b/examples/guessing.sloth
@@ -20,7 +20,8 @@ fn main() Int {
}
print("It took you ");
- print(istr(tries));
+ var s: String = istr(tries);
+ print(s);
println(" to guess correctly!");
return 0;
diff --git a/examples/system.sloth b/examples/system.sloth
new file mode 100644
index 0000000..affe588
--- /dev/null
+++ b/examples/system.sloth
@@ -0,0 +1,5 @@
+fn main() Int {
+ system("neofetch");
+ println(istr(12));
+ return 0;
+}