Metronome: Difference between revisions

Content added Content deleted
m (added an image to the task's preamble.)
Line 459: Line 459:
_ <- getChar
_ <- getChar
putMVar b [Stop]</lang>
putMVar b [Stop]</lang>

=={{header|J}}==
<lang j>
NB. Basic tacit version; this is probably considered bad coding style. At least I removed the "magic constants". Sort of.
'BEL BS LF'=: 7 8 10 { a.
'print delay'=: 1!:2&4`(6!:3)
met=: _&$: :((] ({:@] [ LF print@[ (-.@{.@] [ delay@[ print@] (BEL,2#BS) , (2 2$'\ /') {~ {.@])^:({:@])) 1 , <.@%) 60&% [ print@('\ '"_))
</lang>
{{out}}
<pre>
NB. (t met f) prints a bell character followed by a little "animation"
NB. at f beats per minute for t seconds. It returns the total number
NB. of beats.
10 met 60
\
10

7.5 met 120
/
15
NB. Monadic case sets t to infinity, so you can go insane without
NB. worrying about the metronome ever stopping.
met 42
\ . . .
</pre>


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==