Show ASCII table: Difference between revisions
→{{header|langur}}
(→{{header|ALGOL 68}}: Show the table vertically as with most of the other samples) |
Langurmonkey (talk | contribs) |
||
(16 intermediate revisions by 9 users not shown) | |||
Line 438:
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
# generate an ascii table for characters 32 - 127 #
FOR c FROM 32 TO 32 + 15 DO
FOR
, IF
ELSE " " +
)
)
</syntaxhighlight>
{{out}}
Line 475 ⟶ 473:
=={{header|ALGOL W}}==
This assumes the ASCII character set is used by the Algol W compiler/runtime - the original Algol W implementation used EBCDIC.
<syntaxhighlight
for i := 32 until 32 + 15 do begin
for
end for_ach
end for_i.
</syntaxhighlight>
{{out}}
<pre>
47: / 63: ? 79: O 95: _ 111: o 127: Del
</pre>
=={{header|APL}}==
Line 2,187 ⟶ 2,186:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del</pre>
=={{header|EasyLang}}==
{{trans|AWK}}
<syntaxhighlight lang="easylang">
numfmt 0 3
for i range0 16
for j = 32 + i step 16 to 127
if j = 32
x$ = "Spc"
elif j = 127
x$ = "Del"
else
x$ = strchar j & " "
.
write j & ": " & x$
.
print ""
.
</syntaxhighlight>
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module
@Inject Console console;
void run() {
for (Int offset : 0..<16) {
for (Int ascii = 32+offset;
console.print($|{ascii.toString().rightJustify(3)}/\
|{ascii.toByte().toByteArray()}: \
|{new Char(ascii).quoted().leftJustify(5)}
, suppressNewline=True);
}
console.print();
}
}
}
</syntaxhighlight>
Line 3,062 ⟶ 3,077:
=={{header|Fōrmulæ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Show_ASCII_table}}
'''Solution'''
[[File:Fōrmulæ - Show ASCII table 01.png]]
[[File:Fōrmulæ - Show ASCII table 02.png]]
=={{header|FutureBasic}}==
Line 3,074 ⟶ 3,090:
local fn ASCIITable as CFStringRef
NSinteger i
CFStringRef temp
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
for i = 32 to 127
temp = fn StringWithFormat( @"%c", i )
if i == 32 then temp = @"Spc"
if i ==
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-1d : %@\n", i, temp ) )
next
CFArrayRef colArr = fn StringComponentsSeparatedByString( mutStr, @"\n" )
for i = 0 to 15
ObjectRef col0 = fn StringUTF8String( fn ArrayObjectAtIndex( colArr, i ) )
ObjectRef
ObjectRef
ObjectRef
ObjectRef
ObjectRef
MutableStringAppendString( mutStr, fn StringWithFormat( @"%-10s %-10s %-10s %-10s %-10s %-10s\n", col0, col1, col2, col3, col4, col5 ) )
next
end fn = fn StringWithString( mutStr )
Line 3,122 ⟶ 3,137:
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
=={{header|Go}}==
Line 3,250 ⟶ 3,264:
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del </pre>
=={{Header|Insitux}}==
<syntaxhighlight lang="insitux">
(-> (for i (range 16)
j (range (+ i 32) 128 16)
(let k (match j 32 "Spc" 127 "Del" (str (char-code j) " ")))
(strn ((< j 100) " ") j " : " k))
(partition 6)
(map (join " "))
(join "\n"))
</syntaxhighlight>
{{out}}
<pre>
32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
33 : ! 49 : 1 65 : A 81 : Q 97 : a 113 : q
34 : " 50 : 2 66 : B 82 : R 98 : b 114 : r
35 : # 51 : 3 67 : C 83 : S 99 : c 115 : s
36 : $ 52 : 4 68 : D 84 : T 100 : d 116 : t
37 : % 53 : 5 69 : E 85 : U 101 : e 117 : u
38 : & 54 : 6 70 : F 86 : V 102 : f 118 : v
39 : ' 55 : 7 71 : G 87 : W 103 : g 119 : w
40 : ( 56 : 8 72 : H 88 : X 104 : h 120 : x
41 : ) 57 : 9 73 : I 89 : Y 105 : i 121 : y
42 : * 58 : : 74 : J 90 : Z 106 : j 122 : z
43 : + 59 : ; 75 : K 91 : [ 107 : k 123 : {
44 : , 60 : < 76 : L 92 : \ 108 : l 124 : |
45 : - 61 : = 77 : M 93 : ] 109 : m 125 : }
46 : . 62 : > 78 : N 94 : ^ 110 : n 126 : ~
47 : / 63 : ? 79 : O 95 : _ 111 : o 127 : Del
</pre>
=={{header|J}}==
Line 3,945 ⟶ 3,989:
end
prt(Tbl) # format and print table on console</syntaxhighlight>
=={{header|K}}==
{{works with|ngn/k}}
<syntaxhighlight lang=K>`0:"\n"/" "/'+6 16#{-6$($x),-2$`c$x}'32+!96
32 48 0 64 @ 80 P 96 ` 112 p
33 ! 49 1 65 A 81 Q 97 a 113 q
34 " 50 2 66 B 82 R 98 b 114 r
35 # 51 3 67 C 83 S 99 c 115 s
36 $ 52 4 68 D 84 T 100 d 116 t
37 % 53 5 69 E 85 U 101 e 117 u
38 & 54 6 70 F 86 V 102 f 118 v
39 ' 55 7 71 G 87 W 103 g 119 w
40 ( 56 8 72 H 88 X 104 h 120 x
41 ) 57 9 73 I 89 Y 105 i 121 y
42 * 58 : 74 J 90 Z 106 j 122 z
43 + 59 ; 75 K 91 [ 107 k 123 {
44 , 60 < 76 L 92 \ 108 l 124 |
45 - 61 = 77 M 93 ] 109 m 125 }
46 . 62 > 78 N 94 ^ 110 n 126 ~
47 / 63 ? 79 O 95 _ 111 o 127</syntaxhighlight>
=={{header|Kotlin}}==
Line 4,069 ⟶ 4,133:
=={{header|langur}}==
{{trans|Go}}
<syntaxhighlight lang="langur">for .i of 16 {
for .j = 31 + .i ; .j < 128 ; .j += 16 {
val .L =
write
}
writeln()
}
</syntaxhighlight>
{{out}}
Line 4,678 ⟶ 4,742:
=={{header|PL/M}}==
<syntaxhighlight lang="pli">
100H: /* SHOW AN ASCII TABLE FROM 32 TO 127 */
/* CP/M BDOS SYSTEM CALL */
BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 4,694 ⟶ 4,759:
END PR$BYTE;
/* ASCII TABLE */
DECLARE ( A, C ) BYTE;
DO C = 32 TO
CALL PR$
ELSE
CALL PR$CHAR( '
CALL PR$CHAR(
CALL PR$CHAR( ' ' );
END;
END;
END;
EOF
</syntaxhighlight>
{{out}}
<pre>
032: SPC
</pre>
Line 6,087 ⟶ 6,155:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
for (i in 0...16) {
|