Periodic table: Difference between revisions
→{{header|Quackery}}: improved efficiency
m (→{{header|Quackery}}: tidied up code layout) |
(→{{header|Quackery}}: improved efficiency) |
||
Line 2,102:
=={{header|Quackery}}==
A lookup table is precomputed at compile time from a representation of the periodic table.
<syntaxhighlight lang="Quackery"> [ this ] is ... ( --> ... )▼
[ dup 1 119 within not if▼
[ $ "Unknown element" fail ]▼
( 4 ) 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ▼
( 5 ) 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 ▼
( 6 ) 55 56 ... 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 ▼
( 7 ) 87 88 ... 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 ▼
( 9 ) ... ... ... 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ]▼
find 18 /mod ▼
1+ dip 1+ join ] is task ( n --> [ )▼
▲<syntaxhighlight lang="Quackery"> [ dup 1 119 within not if
' [ 1 2 29 42 57 58 59 71 72 89 90 103 113 ] ▼
▲ [ $ "Unknown element." fail ]
[ table 0
[ 118 times
[ i^ 1+
' [ 1 - - - - - - - - - - - - - - - - 2
11 12 - - - - - - - - - - 13 14 15 16 17 18
- - - 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
find
join nested
witheach
[ dup echo say " --> " task echo cr ]</syntaxhighlight>
Line 2,126 ⟶ 2,129:
{{out}}
<pre>1
2
29
42
57
58
59
71
72
89
90
103
113
</pre>
|