Skip to content

Commit 28c6210

Browse files
committed
First Kotlin examples
1 parent 5009190 commit 28c6210

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

kotlin/hello.kts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
println("Hello, world")

kotlin/test.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
kotlinc -script hello.kts && \
3+
kotlinc -script triple.kts | diff ../test/triple_expected -
4+
5+
if [ $? -ne 0 ]; then
6+
echo
7+
echo "*** KOTLIN TESTS FAILED ***"
8+
exit 1
9+
else
10+
echo
11+
echo "KOTLIN TESTS PASSED"
12+
fi

kotlin/triple.kts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
for (c in 1..40) {
2+
for (b in 1..c-1) {
3+
for (a in 1..b-1) {
4+
if (a * a + b * b == c * c) {
5+
println("${a}, ${b}, ${c}");
6+
}
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)