From 34d6a5d767f3cfba2ecd3cc3dbe355e89e157d6f Mon Sep 17 00:00:00 2001 From: brett_langdon Date: Wed, 30 May 2012 22:22:08 -0400 Subject: [PATCH] Edited chapter 3 intro. Added Variables section to chapter 3 --- 2 - Getting Started/1.2 - Sudo Language.tex | 18 +++---- .../1.1 - Variables.tex | 53 +++++++++++++++++++ .../Functional Programming.tex | 10 ++-- Programming In General.tex | 3 ++ 4 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 3 - Functional Programming/1.1 - Variables.tex diff --git a/2 - Getting Started/1.2 - Sudo Language.tex b/2 - Getting Started/1.2 - Sudo Language.tex index 72cbd41..2cec9aa 100644 --- a/2 - Getting Started/1.2 - Sudo Language.tex +++ b/2 - Getting Started/1.2 - Sudo Language.tex @@ -20,7 +20,7 @@ variable name is equal to the value "Brett", if so then we want to print "Name I print "Name Is Not Brett". As far as programming goes this is a fairly simple process but lets try and translate this example to a few different languages to see how it is done. -PHP: +{\bf PHP:} \begin{lstlisting} getName() === 'Brett' ){ } \end{lstlisting} -Java: +{\bf Java:} \begin{lstlisting} class Person{ private String name; @@ -168,7 +168,7 @@ class Person{ } \end{lstlisting} -Node.Js: +{\bf Node.JS:} \begin{lstlisting} var Person = function(){} Person.prototype.getName = function(){ @@ -188,7 +188,7 @@ if( p.getName() == "Brett" ){ } \end{lstlisting} -Python: +{\bf Python:} \begin{lstlisting} class Person: def getname( self ): diff --git a/3 - Functional Programming/1.1 - Variables.tex b/3 - Functional Programming/1.1 - Variables.tex new file mode 100644 index 0000000..662c09c --- /dev/null +++ b/3 - Functional Programming/1.1 - Variables.tex @@ -0,0 +1,53 @@ +For starters we are going to cover some basic usage of variables. Variables are used to store values to be read and manipulated. +For example we can create a variable named "name" and store the value of the string "Brett" in it. +\begin{lstlisting} +name = "Brett" +\end{lstlisting} + +Fairly simple to start with. +\newline +\\ + +So here we are storing a string into a variable but what about other types of data? Each programming language supports different data types +but for the most part they all support numbers, usaully various types, strings as well as booleans (true or false).So, we can store these +different data types in variables as well. + +\begin{lstlisting} +name = "Brett" +number = 10 +boolean = false +\end{lstlisting} + +Great, we can store values into a variable to use, but what do you mean use them? Well we can either use the variable names to access +the values that we stored in them or we can manipulate the values stored in variables. + +\begin{lstlisting} +name = "Brett" +print name +\end{lstlisting} + +Here we are storing the string "Brett" into the variable "name" and then printing the value stored in name. Here we are showing that +we can access the original string value "Brett" from the variable "name". + +\begin{lstlisting} +a = 10 +b = 5 +c = a + b +print c +\end{lstlisting} + +Ok, so here we are taking the number, or integer, value 10 and storing it into the variable "a", and the integer value 5 and storing it into +the variable "b". Then we are using the mathematical opperator for addition (+) to store the addition of the values stored by +"a" and "b" into the variable "c". Lastly, we are printing the value of "c" which if all works as we would like would print "15". +\newline +This is another example of showing how we can access the values stored within variables and act upon them. In this case we are accessing +the values 10, stored in "a", and 5, stored in "b", and performing mathematical opperations on them. + +\begin{lstlisting} +a = 10 +a = a + 5 +print a +\end{lstlisting} + +In this example we are storing the integer value 10 into the variable "a" and then we are manipulating the value of a in such a way that we +are adding the integer value 5 to it. Lastly, we are printing the final value of "a", which will be "15". diff --git a/3 - Functional Programming/Functional Programming.tex b/3 - Functional Programming/Functional Programming.tex index 179e551..b4ebb4a 100644 --- a/3 - Functional Programming/Functional Programming.tex +++ b/3 - Functional Programming/Functional Programming.tex @@ -5,7 +5,11 @@ definition of functional programming but to try and keep things simple and organ refer to it as. \newline \\ -Functional Programming: +I am going to use this chapter to introduce topics other than just functions. Topics including control statements, loops and some input output (io). \newline ---insert definition here-- - +\\ +{\bf Functional Programming:} +\\ +Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. +\newline +Wikipedia (2012) diff --git a/Programming In General.tex b/Programming In General.tex index 12c3c9a..94375e1 100644 --- a/Programming In General.tex +++ b/Programming In General.tex @@ -36,6 +36,9 @@ \chapter{Functional Programming} \input{"./3 - Functional Programming/Functional Programming"} +\section{Variables} +\input{"./3 - Functional Programming/1.1 - Variables"} + \chapter{Object Oriented Programming} \input{"./4 - Object Oriented Programming/Object Oriented Programming"}