CSV to HTML translation: Difference between revisions

m (→‎{{header|Go}}: User new and more efficient strings.Builder)
Line 555:
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</tbody></table></lang>
 
Newer versions of Bracmat have the built in function <code>vap</code> that splits an input string in
single characters or that splits it everywhere where a given separator character occurs. Each single character or slab of characters is
passed to a function. The values returned from this function become the elements in a list that is returned from the <code>vap</code> function. For example, <code>vap$(upp.Википедию)</code> "vaporizes" the word Википедию into characters and produces the list of
uppercased characters В И К И П Е Д И Ю. Instead of the name of a function we can choose to just give <code>vap</code> the definition of an anonymous function, like so: <code>vap$((=.!arg:~и|).Википедию)</code>. This returns a list of the characters in the word Википедию, except for the и character: В к п е д ю.
 
In the code below, we use <code>vap</code> with a third argument, a splitting separator character. The outer call to <code>vap</code> splits a text into rows. An embedded call to <code>vap</code> splits each row into cell elements. This code is very efficient.
<lang Bracmat>( ( Csv2Html
=
. toML
$ ( table
.
, vap
$ ( (
= .tr.,vap$((=.td.,!arg).!arg.",")
)
. !arg
. \n
)
)
)
& Csv2Html
$ "Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!
"
)</lang>
 
=={{header|Befunge}}==
483

edits