CSV to HTML translation: Difference between revisions

→‎{{header|Perl 6}}: added some comments
(→‎{{header|Perl 6}}: added some comments)
Line 1,923:
 
=={{header|Perl 6}}==
 
I'm not sure why this looks so messy, tried my best with comments, but this very funtional approach seems very unreadable.
 
 
<lang Perl 6>
Line 1,930 ⟶ 1,933:
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!¦; # ww
 
my &escape = *.trans([ <& < \>>] => [<&amp; &lt; &gt;> ]); # a function with one argument that escapes the entities
my &tag = {"<$^t>"~$^s~"</$^t>"}; # ~~a function that takes a string and a tagname, and tags it
 
printf #printf statement
'<!DOCTYPE html>
<html>
<head><title>Some Text</title></head>
<body><table>%s
%s
</table></body></html>
', [~] escape($str).split(/\n/).map(-> $l { # concatenation reduction, escape the string, then split it at \n, then anonymous function
state $first //= 0; # state variable for considering if it is the first line (no ff implemented, yet)
state $first //= 0;
#tag(([~] $l.it with tr, split(/ at ','/).map({ ==> tag($^a, those as td if $first++ ??(which 'td'means !!'th'the )}))first time it will be false,'tr' then true)}); alse as th
tag(([~] $l.split(/','/).map({tag($^a, $first++ ?? 'td' !!'th' )})),'tr')});
</lang>
 
 
=={{header|PicoLisp}}==
38

edits