Skip to content

Commit 1943741

Browse files
committed
Added koka programming language examples
1 parent ae5eb8d commit 1943741

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

koka/clockhands.kk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fun pad(n:int)
2+
pad-left(show(n), 2, '0')
3+
4+
fun main()
5+
for(0,10) fn(i)
6+
var t := (43200 * i + 21600) / 11
7+
var h := t / 3600
8+
var m := t / 60 % 60
9+
var s := t % 60
10+
println(pad(if is-zero(h) then 12 else h) ++ ":" ++ pad(m) ++ ":" ++ pad(s))

koka/hello.kk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun main()
2+
println("Hello, World!")

koka/test.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$Error.clear()
12+
koka -v0 -e "$PSScriptRoot\clockhands.kk" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
koka -v0 -e "$PSScriptRoot\hello.kk" &&
16+
ForEach-Object 'foo'
17+
18+
if ($Error -or !$?) {
19+
"*** KOKA TESTS FAILED ***"
20+
}
21+
else {
22+
"KOKA TESTS PASSED"
23+
}

0 commit comments

Comments
 (0)