Periodic table: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added Easylang)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by 2 users not shown)
Line 715:
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|Quite BASIC}}===
{{trans|Minimal BASIC}}
<syntaxhighlight lang="qbasic">10 REM Periodic table
20 GOSUB 200
30 FOR J = 0 TO 9
40 READ N
50 GOSUB 400
60 NEXT J
70 END
190 REM Set arrays A, B.
200 ARRAY A
210 LET A[0] = 1
215 LET A[1] = 2
220 LET A[2] = 5
225 LET A[3] = 13
230 LET A[4] = 57
235 LET A[5] = 72
240 LET A[6] = 89
245 LET A[7] = 104
246 ARRAY B
250 LET B[0] = -1
255 LET B[1] = 15
260 LET B[2] = 25
265 LET B[3] = 35
270 LET B[4] = 72
275 LET B[5] = 21
280 LET B[6] = 58
285 LET B[7] = 7
290 RETURN
390 REM Show row and column for element
400 LET I = 7
410 IF A(I) <= N THEN 440
420 LET I = I-1
430 GOTO 410
440 LET M = N+B(I)
450 LET R = INT(M/18)+1
460 LET C = M-INT(M/18)*18+1
470 PRINT N; " -> "; R; " "; C
480 RETURN
1030 REM Example elements (atomic numbers).
1040 DATA 1, 2, 29, 42, 57, 58, 72, 89, 90, 103</syntaxhighlight>
 
==={{header|Run BASIC}}===
Line 2,160 ⟶ 2,202:
103 -> [ 9 18 ]
113 -> [ 7 13 ]
</pre>
 
We can confirm that the lookup table was created during compilation by decompiling the word <code>task</code> with <code>' task copy unbuild echo$</code>.
 
{{out}}
 
<pre>[ dup 1 119 within not if [ [ ' [ 85 110 107 110 111 119 110 32 101 108 101 109 101 110 116 ] ] fail ] [ table 0 [ 1 1 ] [ 1 18 ] [ 2 1 ] [ 2 2 ] [ 2 13 ] [ 2 14 ] [ 2 15 ] [ 2 16 ] [ 2 17 ] [ 2 18 ] [ 3 1 ] [ 3 2 ] [ 3 13 ] [ 3 14 ] [ 3 15 ] [ 3 16 ] [ 3 17 ] [ 3 18 ] [ 4 1 ] [ 4 2 ] [ 4 3 ] [ 4 4 ] [ 4 5 ] [ 4 6 ] [ 4 7 ] [ 4 8 ] [ 4 9 ] [ 4 10 ] [ 4 11 ] [ 4 12 ] [ 4 13 ] [ 4 14 ] [ 4 15 ] [ 4 16 ] [ 4 17 ] [ 4 18 ] [ 5 1 ] [ 5 2 ] [ 5 3 ] [ 5 4 ] [ 5 5 ] [ 5 6 ] [ 5 7 ] [ 5 8 ] [ 5 9 ] [ 5 10 ] [ 5 11 ] [ 5 12 ] [ 5 13 ] [ 5 14 ] [ 5 15 ] [ 5 16 ] [ 5 17 ] [ 5 18 ] [ 6 1 ] [ 6 2 ] [ 8 4 ] [ 8 5 ] [ 8 6 ] [ 8 7 ] [ 8 8 ] [ 8 9 ] [ 8 10 ] [ 8 11 ] [ 8 12 ] [ 8 13 ] [ 8 14 ] [ 8 15 ] [ 8 16 ] [ 8 17 ] [ 8 18 ] [ 6 4 ] [ 6 5 ] [ 6 6 ] [ 6 7 ] [ 6 8 ] [ 6 9 ] [ 6 10 ] [ 6 11 ] [ 6 12 ] [ 6 13 ] [ 6 14 ] [ 6 15 ] [ 6 16 ] [ 6 17 ] [ 6 18 ] [ 7 1 ] [ 7 2 ] [ 9 4 ] [ 9 5 ] [ 9 6 ] [ 9 7 ] [ 9 8 ] [ 9 9 ] [ 9 10 ] [ 9 11 ] [ 9 12 ] [ 9 13 ] [ 9 14 ] [ 9 15 ] [ 9 16 ] [ 9 17 ] [ 9 18 ] [ 7 4 ] [ 7 5 ] [ 7 6 ] [ 7 7 ] [ 7 8 ] [ 7 9 ] [ 7 10 ] [ 7 11 ] [ 7 12 ] [ 7 13 ] [ 7 14 ] [ 7 15 ] [ 7 16 ] [ 7 17 ] [ 7 18 ] ] ]
 
</pre>
 
Line 2,298 ⟶ 2,348:
{{libheader|Wren-fmt}}
There is a discrepancy between how the periodic table is arranged in the Wikipedia article and how it is arranged in the task description. I've used the latter in the following script.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var limits = [3..10, 11..18, 19..36, 37..54, 55..86, 87..118]
9,482

edits