Browse Source

Edited chapter 3 intro. Added Variables section to chapter 3

pull/1/head
Brett Langdon 14 years ago
parent
commit
34d6a5d767
4 changed files with 72 additions and 12 deletions
  1. +9
    -9
      2 - Getting Started/1.2 - Sudo Language.tex
  2. +53
    -0
      3 - Functional Programming/1.1 - Variables.tex
  3. +7
    -3
      3 - Functional Programming/Functional Programming.tex
  4. +3
    -0
      Programming In General.tex

+ 9
- 9
2 - Getting Started/1.2 - Sudo Language.tex View File

@ -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}
<?php
$name = 'Brett';
@ -31,7 +31,7 @@ if( $name === 'Brett' ){
}
\end{lstlisting}
C:
{\bf C:}
\begin{lstlisting}
int main{
char* name = "Brett";
@ -44,7 +44,7 @@ int main{
}
\end{lstlisting}
Python:
{\bf Python:}
\begin{lstlisting}
name = "Brett"
if name is "Brett":
@ -53,7 +53,7 @@ else:
print "Name Is Not Brett"
\end{lstlisting}
Node.JS:
{\bf Node.JS:}
\begin{lstlisting}
var name = "Brett";
if( name == "Brett" ){
@ -63,7 +63,7 @@ if( name == "Brett" ){
}
\end{lstlisting}
Java:
{\bf Java:}
\begin{lstlisting}
class Example1{
public static void main( String[] args ){
@ -116,7 +116,7 @@ in the previous example we are going to get if the value of "p"'s private proper
Like I mentioned before, this example might go over the head of some people as it introduces some more advanced topics, but hopefully it
helps to understand how you can translate the sudo language.
PHP:
{\bf PHP:}
\begin{lstlisting}
<?php
class Person{
@ -141,7 +141,7 @@ if( $p->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 ):


+ 53
- 0
3 - Functional Programming/1.1 - Variables.tex View File

@ -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".

+ 7
- 3
3 - Functional Programming/Functional Programming.tex View File

@ -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)

+ 3
- 0
Programming In General.tex View File

@ -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"}


Loading…
Cancel
Save