A Structured Foray into LaTeX

I am trying to follow this guide: en.wikibooks.org/wiki/LaTeX/Basics, so I ran sudo apt-get install texlive-latex-base to prep my linux environment for our first realistic steps into Mr. Knuth’s word processing apparatus.

Our template.tex file:

% <- this character begins comments

%article is one of any document classs

%we can change the document class to
% change the appearance of this document
documentclass{article}

%everything above this line is the preamble
%document is considered an environment
begin{document}
Hello World!
end{document}
 

Output of latex template.tex

~/Scripts/LaTeX$ latex template.tex 
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(./template.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size10.clo))
No file template.aux.
[1] (./template.aux) )
Output written on template.dvi (1 page, 232 bytes).
Transcript written on template.log.

Messing with Perl


sub zipper {
my ($left, $right) = @_;
my @larr = @{$left};
my $lsize = @larr;

my @rarr = @{$right};
my $rsize = @rarr;

if ($lsize != $rsize) {

die "Array sizes are inequal.";

}



my @AoAr;

for (my $i = 0; $i < $lsize; $i++) {
push @AoAr, ($larr[$i], $rarr[$i]), "n";
}

return @AoAr;

}

Earlier I decided to make a zipper subroutine in Perl. So far it works. Results:


$VAR1 = 'Pat';
$VAR2 = '1';
$VAR3 = '
';
$VAR4 = 'Sean';
$VAR5 = '2';
$VAR6 = '
';
$VAR7 = 'Dante';
$VAR8 = '3';
$VAR9 = '
';
$VAR10 = 'Dustin';
$VAR11 = '4';
$VAR12 = '
';

I also devised a dot product using two maps:


my @dotproduct = map {my $z = $_; map {$z . ' ' . $_}
@surnames} @names;

Results:


$VAR1 = 'Pat 1';
$VAR2 = 'Pat 2';
$VAR3 = 'Pat 3';
$VAR4 = 'Pat 4';
$VAR5 = 'Sean 1';
$VAR6 = 'Sean 2';
$VAR7 = 'Sean 3';
$VAR8 = 'Sean 4';
$VAR9 = 'Dante 1';
$VAR10 = 'Dante 2';
$VAR11 = 'Dante 3';
$VAR12 = 'Dante 4';
$VAR13 = 'Dustin 1';
$VAR14 = 'Dustin 2';
$VAR15 = 'Dustin 3';
$VAR16 = 'Dustin 4';

Another fine example of bad programming. Now here are some things I should have learned way earlier:

  • Lists are not the same as arrays. Arrays are filled with scalars. Lists have objects of some sort.
  • Lists don’t really have a scalar context. It resolves to their last element.
  • Changing from an array reference to an array is way too clunky. Is there a better way?