RosettaCodeData/Task/Periodic-table/Phix/periodic-table-2.phix
2026-02-01 16:33:20 -08:00

52 lines
2.5 KiB
Text

constant ptxt = """
__________________________________________________________________________
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
| |
|1 H He |
| |
|2 Li Be B C N O F Ne |
| |
|3 Na Mg Al Si P S Cl Ar |
| |
|4 K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr |
| |
|5 Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe |
| |
|6 Cs Ba * Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn |
| |
|7 Fr Ra + Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og |
|__________________________________________________________________________|
| |
| |
|8 Lantanoidi* La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu |
| |
|9 Aktinoidi+ Ak Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr |
|__________________________________________________________________________|
"""
function tablify(string ptxt)
sequence lines = split(ptxt,"\n"),
res = {}
for l in lines do
integer ln = l[2]-'0', c = 0
if ln>=1 and ln<=9 then
res = append(res,{})
for j=5 to length(l) by 4 do
c += 1
if l[j]>='A' and l[j+2]<=' ' then
res[$] = append(res[$],{trim(l[j..j+1]),ln,c})
end if
end for
end if
end for
res[7][3..2] = res[9]
res[6][3..2] = res[8]
res = join(res[1..7],{},{})
return res
end function
constant pt = apply(true,sprintf,{{"(%s) is at %d, %d"},tablify(ptxt)})
for e in {1,2,29,42,57,58,59,71,72,89,90,103,113} do
printf(1,"Element %d %s\n",{e,pt[e]})
end for