Anonymous user
Read a configuration file: Difference between revisions
Replaced “f.lines” with “"demo.config.lines()” avoiding expliciting "f". Replaced the OrderedTableRef with an OrderedTable. Some other minor changes.
m (→{{header|Phix}}: added syntax colouring the hard way) |
(Replaced “f.lines” with “"demo.config.lines()” avoiding expliciting "f". Replaced the OrderedTableRef with an OrderedTable. Some other minor changes.) |
||
Line 3,116:
=={{header|Nim}}==
<lang Nim>import re, strformat, strutils, tables
var configs:
var parsed: seq[string]
for line in
if line
for key in ["fullname", "favouritefruit", "needspeeling", "seedsremoved", "otherfamily"]:▼
▲for key in ["fullname", "favouritefruit", "needspeeling", "seedsremoved",
if not configs.hasKey(key):
echo(&"{key} = false")
Line 3,141 ⟶ 3,137:
else:
for i, v in configs[key].pairs():
echo(&"{key}({i+1}) = {v}")</lang>
{{out}}
<pre>
|