Skip to content

Commit 489f7bf

Browse files
committed
started working on section 3.1 variables
1 parent 5f8588a commit 489f7bf

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

3 - Functional Programming/1.1 - Variables.tex

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,73 @@ \subsection{Data Types}
4444
variable on declaration (unlike our sudo language).
4545

4646

47-
\subsection{Operations}
47+
\subsection{Operators}
48+
Operators are symbols we can use to manipulate variables.
49+
There are a few different types of operators, Arithmetic, Comparison and Logical operators.
50+
A quick list of operators include:
51+
52+
\begin{enumerate}
53+
\item Addition +
54+
\item Subtraction -
55+
\item Multiplication *
56+
\item Division /
57+
\item Equals =
58+
\item Equal To ==
59+
\item Not Equal To !=
60+
\item Less Than <
61+
\item Greater Than >
62+
\item Logical AND \&\&
63+
\end{enumerate}
64+
65+
And there are more!
66+
\par
67+
68+
Arithmetic operators include the mathematical symbols for addition (+), subtractions (-), division(/), multiplication(*) and equals(=).
69+
These operators are used to directly manipulate and change variables.
70+
For example we can add two variables together and then store that sum into a third variable.
71+
72+
\begin{lstlisting}[caption={Addition Operator}]
73+
a = 10
74+
b = 5
75+
c = a + b
76+
77+
print c
78+
\end{lstlisting}
79+
80+
We store the value of \pigVal{10} into the variable \pigVar{a} and the value \pigVal{5} into the variable \pigVar{b}.
81+
Lastly, we store the sum of the variables \pigVar{a} and \pigVar{b} into the variable \pigVar{c}.
82+
The output of this program will be \pigOut{15}.
83+
\par
84+
85+
Comparison operators are used to compare variables against other variables or values.
86+
The output of a comparison operator will be a boolean value (\pigVal{true} or \pigVal{false}).
87+
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 (>=).
88+
89+
\begin{lstlisting}[caption={Comparison Operators}]
90+
name = ``Brett''
91+
a = 10
92+
b = 5
93+
c = a + b
94+
95+
96+
if name == ``Brett'':
97+
print ``Name is Brett''
98+
99+
if a > 10:
100+
print ``A is greater than 10''
101+
102+
if b >= 5:
103+
print ``B is greater than or equal to 5''
104+
105+
if c != 6:
106+
print ``C is not 6''
107+
\end{lstlisting}
108+
109+
In this example we are showing a few of the comparison operators.
110+
The output of this code will be:\\*
111+
\pigOut{Name is Brett\\*
112+
B is greater than or equal to 5\\*
113+
C is not 6}.
48114

49115
\subsection{Conclusion}
50116

Programming In General.pdf

11.3 KB
Binary file not shown.

Programming In General.tex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ \section{Control Statements}
151151
\input{"./3 - Functional Programming/1.2 - Control Statements"}
152152
\vfill
153153
\pagebreak
154-
\section{Control Statements~}
155-
\input{"./3 - Functional Programming/1.2 - Control Statements~"}
156-
\vfill
157-
\pagebreak
158154
\section{Functions}
159155
\input{"./3 - Functional Programming/1.3 - Functions"}
160156
\vfill
@@ -167,10 +163,6 @@ \section{Classes and Objects}
167163
\input{"./4 - Object Oriented Programming/1.1 - Classes and Objects"}
168164
\vfill
169165
\pagebreak
170-
\section{Classes and Objects~}
171-
\input{"./4 - Object Oriented Programming/1.1 - Classes and Objects~"}
172-
\vfill
173-
\pagebreak
174166
\section{Inheritence}
175167
\input{"./4 - Object Oriented Programming/1.2 - Inheritence"}
176168
\vfill

build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ book.write(header.read());
1111
header.close();
1212

1313
dirs = [x[0] for x in os.walk('.')][1:]
14-
14+
dirs.sort()
1515
for d in filter(lambda d: not re.search('.git',d),dirs):
1616
chapter = re.sub('\d+\s-\s', '', d[2:])
17+
print chapter
1718
book.write('\r\n\chapter{' + chapter + '}\r\n')
1819
if os.path.exists(d + '/' + chapter + '.tex'):
1920
book.write('\input{"' + d + '/' + chapter + '"}\r\n')
2021
book.write('\\vfill\r\n\pagebreak')
2122
files = os.listdir(d)
23+
files.sort()
2224
for f in filter(lambda f: re.search('^\d+.\d+\s-\s',f), files):
2325
section = re.sub('\d+.\d+\s-\s|.tex', '', f)
26+
print section
2427
book.write('\r\n\section{' + section + '}\r\n')
2528
book.write('\input{"' + d + '/' + f.replace('.tex', '') + '"}\r\n')
2629
book.write('\\vfill\r\n\pagebreak')

0 commit comments

Comments
 (0)