Jump to content

Metronome: Difference between revisions

Added Kotlin
No edit summary
(Added Kotlin)
Line 552:
}
</lang>
 
=={{header|Kotlin}}==
<lang scala>// version 1.1.2
 
fun metronome(bpm: Int, bpb: Int, maxBeats: Int = Int.MAX_VALUE) {
val delay = 60_000L / bpm
var beats = 0
do {
Thread.sleep(delay)
if (beats % bpb == 0) print("\nTICK ")
else print("tick ")
beats++
}
while (beats < maxBeats)
println()
}
 
fun main(args: Array<String>) = metronome(120, 4, 20) // limit to 20 beats </lang>
 
{{out}}
<pre>
TICK tick tick tick
TICK tick tick tick
TICK tick tick tick
TICK tick tick tick
TICK tick tick tick
</pre>
 
=={{header|Liberty BASIC}}==
9,487

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.