Long literals, with continuations: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: Incorrectly marked incorrect)
Line 250: Line 250:
Length of element list: 118
Length of element list: 118
last element in list: Oganesson
last element in list: Oganesson
</pre>

=={{header|Phix}}==
Back-ticks and triple-quotes permit multi-line strings. We first replace all/any cr/lf/tab characters with spaces, then split (by default on a single space), omitting empty elements. You could use spaced_elements = join(elements) to join them back up into a space-separated single string, if that's really what you want, and you could then, like Go, use rfind(' ',spaced_elements) to re-extract the last one.
You could also, like Julia, use get_file_date(command_line()[2]) instead of the hand-written last_updated constant. Phix code is free-format, indent things however you like, there is no specific maximum line length.
<lang Phix>constant last_updated = "March 24th, 2020",
elements_text = `
hydrogen helium lithium beryllium
boron carbon nitrogen oxygen
fluorine neon sodium magnesium
aluminum silicon phosphorous sulfur
chlorine argon potassium calcium
scandium titanium vanadium chromium
manganese iron cobalt nickel
copper zinc gallium germanium
arsenic selenium bromine krypton
rubidium strontium yttrium zirconium
niobium molybdenum technetium ruthenium
rhodium palladium silver cadmium
indium tin antimony tellurium
iodine xenon cesium barium
lanthanum cerium praseodymium neodymium
promethium samarium europium gadolinium
terbium dysprosium holmium erbium
thulium ytterbium lutetium hafnium
tantalum tungsten rhenium osmium
iridium platinum gold mercury
thallium lead bismuth polonium
astatine radon francium radium
actinium thorium protactinium uranium
neptunium plutonium americium curium
berkelium californium einsteinium fermium
mendelevium nobelium lawrencium rutherfordium
dubnium seaborgium bohrium hassium
meitnerium darmstadtium roentgenium copernicium
nihonium flerovium moscovium livermorium
tennessine oganesson
`,
elements = split(substitute_all(elements_text,"\n\r\t"," "),no_empty:=true),
fmt = """
Last revision: %s
Number of elements: %d
The last of which is: `%s`
"""
printf(1,fmt,{last_updated,length(elements),elements[$]})</lang>
{{out}}
<pre>
Last revision: March 24th, 2020
Number of elements: 118
The last of which is: `oganesson`
</pre>
</pre>