Colour bars/Display
The task is to display a series of vertical color bars across the width of the display. The color bars should either use the system palette, or the sequence of colors: Black, Red, Green, Blue, Magenta, Cyan, Yellow, White.
Tcl
<lang tcl>package require Tcl 8.5 package require Tk 8.5
wm attributes . -fullscreen 1 pack [canvas .c] -fill both -expand 1 set colors {black red green blue magenta cyan yellow white}
for {set x 0} {$x < [winfo screenwidth c]} {incr x 8} {
.c create rectangle $x 0 [expr {$x+7}] [winfo screenheight c] \ -fill [lindex $colors 0] -outline {} set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]]
}</lang>
ZX Spectrum Basic
<lang basic>10 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces 20 FOR r=0 TO 20: REM There are 21 rows 30 FOR c=0 TO 7: REM We use the native colour sequence here 40 PRINT " ";: REM four spaces, the semicolon prevents newline 50 NEXT c 60 REM at this point the cursor has wrapped, so we don't need a newline 70 NEXT r</lang>