Draw a clock: Difference between revisions
Content deleted Content added
No edit summary |
Added PicoLisp |
||
Line 201:
</lang>
=={{header|PicoLisp}}==
This is an animated ASCII drawing of the "Berlin-Uhr", a clock built to display the time according to the principles of set theory, which is installed in Berlin since 1975.
See [http://www.surveyor.in-berlin.de/berlin/uhr/indexe.html www.surveyor.in-berlin.de/berlin/uhr/indexe.html] and [http://www.cs.utah.edu/~hatch/berlin_uhr.html www.cs.utah.edu/~hatch/berlin_uhr.html].
<lang PicoLisp>(de draw Lst
(for L Lst
(for X L
(cond
((num? X) (space X))
((sym? X) (prin X))
(T (do (car X) (prin (cdr X)))) ) )
(prinl) ) )
(de bigBox (N)
(do 2
(prin "|")
(for I 4
(prin (if (> I N) " |" " ======== |")) )
(prinl) ) )
(call 'clear) # Clear screen
(call "tput" "civis") # Set cursor invisible
(push '*Bye '(call "tput" "cnorm")) # Set cursor visible on exit
(loop
(call "tput" "cup" 0 0) # Cursor to top left
(let Time (time (time))
(draw (20 (5 . _)) (19 / 5 \\))
(if (onOff (NIL))
(draw (18 / 7 \\) (18 \\ 7 /))
(draw (18 / 2 (3 . "#") 2 \\) (18 \\ 2 (3 . "#") 2 /)) )
(draw
(19 \\ (5 . _) /)
(+ (10 . -) + (10 . -) + (10 . -) + (10 . -) +) )
(bigBox (/ (car Time) 5))
(draw (+ (10 . -) + (10 . -) + (10 . -) + (10 . -) +))
(bigBox (% (car Time) 5))
(draw (+ (43 . -) +))
(do 2
(prin "|")
(for I `(range 5 55 5)
(prin
(cond
((> I (cadr Time)) " |")
((=0 (% I 3)) " # |")
(T " = |") ) ) )
(prinl) )
(draw (+ (43 . -) +))
(bigBox (% (cadr Time) 5))
(draw (+ (10 . -) + (10 . -) + (10 . -) + (10 . -) +)) )
(wait 1000) )</lang>
The six '#' characters in the "circle" on top toggle on/off every second. This is the display at 17:46:
<pre> _____
/ \
/ ### \
\ ### /
\_____/
+----------+----------+----------+----------+
| ======== | ======== | ======== | |
| ======== | ======== | ======== | |
+----------+----------+----------+----------+
| ======== | ======== | | |
| ======== | ======== | | |
+-------------------------------------------+
| = | = | # | = | = | # | = | = | # | | |
| = | = | # | = | = | # | = | = | # | | |
+-------------------------------------------+
| ======== | | | |
| ======== | | | |
+----------+----------+----------+----------+</pre>
=={{header|Tcl}}==
|