diff --git a/3 - Functional Programming/1.1 - Variables.tex b/3 - Functional Programming/1.1 - Variables.tex index 26d9794..ae14dcb 100644 --- a/3 - Functional Programming/1.1 - Variables.tex +++ b/3 - Functional Programming/1.1 - Variables.tex @@ -44,7 +44,73 @@ As well some programming languages that are strickly typed which requires us to variable on declaration (unlike our sudo language). -\subsection{Operations} +\subsection{Operators} +Operators are symbols we can use to manipulate variables. +There are a few different types of operators, Arithmetic, Comparison and Logical operators. +A quick list of operators include: + +\begin{enumerate} +\item Addition + +\item Subtraction - +\item Multiplication * +\item Division / +\item Equals = +\item Equal To == +\item Not Equal To != +\item Less Than < +\item Greater Than > +\item Logical AND \&\& +\end{enumerate} + +And there are more! +\par + +Arithmetic operators include the mathematical symbols for addition (+), subtractions (-), division(/), multiplication(*) and equals(=). +These operators are used to directly manipulate and change variables. +For example we can add two variables together and then store that sum into a third variable. + +\begin{lstlisting}[caption={Addition Operator}] +a = 10 +b = 5 +c = a + b + +print c +\end{lstlisting} + +We store the value of \pigVal{10} into the variable \pigVar{a} and the value \pigVal{5} into the variable \pigVar{b}. +Lastly, we store the sum of the variables \pigVar{a} and \pigVar{b} into the variable \pigVar{c}. +The output of this program will be \pigOut{15}. +\par + +Comparison operators are used to compare variables against other variables or values. +The output of a comparison operator will be a boolean value (\pigVal{true} or \pigVal{false}). +Some of the popular comparison operators are the equals to (==), not equals to (!=), less than (<), less than equal to (<=), greater than (>) and greater than equal to (>=). + +\begin{lstlisting}[caption={Comparison Operators}] +name = ``Brett'' +a = 10 +b = 5 +c = a + b + + +if name == ``Brett'': + print ``Name is Brett'' + +if a > 10: + print ``A is greater than 10'' + +if b >= 5: + print ``B is greater than or equal to 5'' + +if c != 6: + print ``C is not 6'' +\end{lstlisting} + +In this example we are showing a few of the comparison operators. +The output of this code will be:\\* +\pigOut{Name is Brett\\* +B is greater than or equal to 5\\* +C is not 6}. \subsection{Conclusion} diff --git a/Programming In General.pdf b/Programming In General.pdf index 0697149..0e9528d 100644 Binary files a/Programming In General.pdf and b/Programming In General.pdf differ diff --git a/Programming In General.tex b/Programming In General.tex index cd7e808..f0e53fa 100644 --- a/Programming In General.tex +++ b/Programming In General.tex @@ -151,10 +151,6 @@ Brett \textsc{Langdon} \input{"./3 - Functional Programming/1.2 - Control Statements"} \vfill \pagebreak -\section{Control Statements~} -\input{"./3 - Functional Programming/1.2 - Control Statements~"} -\vfill -\pagebreak \section{Functions} \input{"./3 - Functional Programming/1.3 - Functions"} \vfill @@ -167,10 +163,6 @@ Brett \textsc{Langdon} \input{"./4 - Object Oriented Programming/1.1 - Classes and Objects"} \vfill \pagebreak -\section{Classes and Objects~} -\input{"./4 - Object Oriented Programming/1.1 - Classes and Objects~"} -\vfill -\pagebreak \section{Inheritence} \input{"./4 - Object Oriented Programming/1.2 - Inheritence"} \vfill diff --git a/build b/build index d149d6d..ec620ef 100755 --- a/build +++ b/build @@ -11,16 +11,19 @@ book.write(header.read()); header.close(); dirs = [x[0] for x in os.walk('.')][1:] - +dirs.sort() for d in filter(lambda d: not re.search('.git',d),dirs): chapter = re.sub('\d+\s-\s', '', d[2:]) + print chapter book.write('\r\n\chapter{' + chapter + '}\r\n') if os.path.exists(d + '/' + chapter + '.tex'): book.write('\input{"' + d + '/' + chapter + '"}\r\n') book.write('\\vfill\r\n\pagebreak') files = os.listdir(d) + files.sort() for f in filter(lambda f: re.search('^\d+.\d+\s-\s',f), files): section = re.sub('\d+.\d+\s-\s|.tex', '', f) + print section book.write('\r\n\section{' + section + '}\r\n') book.write('\input{"' + d + '/' + f.replace('.tex', '') + '"}\r\n') book.write('\\vfill\r\n\pagebreak')