SlideShare a Scribd company logo
1 of 16
Download to read offline
INTRO TO SERVER SIDE PROGRAMMING
Lesson Five
Thursday, September 26, 13
Lists and Dictionaries
In computer science, a list (or sequence) is an abstract
data type that implements an ordered collection of
values. Each instance of a value on a list is usually called
an item, entry or element of the list, and if the same value
appears multiple times in the list, each is considered a
distinct item of the list.
An associative array (or dictionary) is an abstract data
type composed of a collection of key/value pairs, such
that each key appears at most once in the collection.
Pairs can be added or removed, and values can be
modified or retrieved based on the associated key.
Thursday, September 26, 13
What's The Difference?
A list is always ordered, can usually return elements or
items by numeric index(starting at zero), and might not
allow modification of values. A decent implementation of
a list should provide specific operations for adding and
removing elements to enable them to be used:
push - append to the end(or tail) of the list
pop - remove from the tail of the list
queue(unshift) - append to the beginning(or head) of the list
dequeue(shift) - remove from the head of the list
A hash is usually not immutable and may be
indeterminately ordered. Values can usually be altered.
Thursday, September 26, 13
Arrays
An array type is a data type that is meant to describe a
collection of values or variables, each selected by one or
more indices(keys) tha can be computed at run-time of the
program.
By default, the array type in PHP generates computed,
numerical indices, starting with zero, to make a list:
var_dump(array( 'one', 'two', 3, 4, 4.1, 4.2 ));
$list = array(); $list[] = 'one'; $list[] = 'two';
The value for the key can also be specified as any scalar
literal (neither array, object nor resource), often a string
var_dump(array( 'one' => 1, 2 => 'two' )):
$list[4] = 'four'; $list['five dot one'] = 5.1;
Thursday, September 26, 13
Array Tricks
PHP relies heavily on arrays, so there are a lot of array-
specific functions, like to use an array as a queue or stack
array_unshift(), array_shift() - append to and remove from head
array_push(), array_pop() - append to and remove from tail
PHP arrays have an "internal position" pointer that can be
used as an iterator:
current(), key() - return the current element or key
next(), prev(), end(), reset() - advance forward or back
each() - return the current key and value and advance the
pointer
Thursday, September 26, 13
Even More Array Tricks
array_merge() - merge two or more arrays
array_slice() - remove an array section
array_splice() - insert or replace a section
count(), sizeof() - calculate length
array_fill(), array_pad(), range() - generate values
str_split(), explode(), implode(), join() - array to string
Thursday, September 26, 13
ASSIGNMENT 5.1
Find Some Lists and Arrays
Thursday, September 26, 13
Lists of Lists
Open Github and Cloud 9
Look through your forked projects for examples of lists
and dictionary definitions and methods
Copy adn paste your examples into a file named
"homework-5.1.md" with code delimiters as needed
Write comments identifying the lists, keys, indexes and
other list and dictionary pieces discussed
Save, add and commit, then push to Github when done
Thursday, September 26, 13
Recursion
Thursday, September 26, 13
Control Flow Statements
Control Flow - refers to the order in which the individual
statements, instructions or function calls of an
imperative or declarative program are executed or
evaluated. Execution results in a choice being made as to
which of two or more paths should be followed.
Types of Control Flow statements:
continuation at a different statement (unconditional branch or jump)
execute statements only if some condition is met (conditional branch)
execute statements until some conditional is met(loop, conditional branch)
execute defined statements and return (sub/co-routines, continuations)s
stop executing statements (unconditional halt)
Thursday, September 26, 13
Loops
A loop is a sequence of statements which is specified once
but which may be carried out several times in succession, a
specified number of times or indefinitely
Specific number of times:
for ( $count = 0; $count < $max; $count++ ) do_something();
Once per each item in a collection(array):
foreach ( $collection as $item ) do_something();
foreach ($collection as $key => $value ) do_something();
Until some condition is met:
while ( $condition == true ) do_something();
do something(); while ( $condition );
Indefinitely(infinitely):
while ( true ) do_something();
do something(); while ( true);
Thursday, September 26, 13
Infinite Loops
An unconditional(or
infinite) loop returns to a
fixed point in the
diagram, usually the top
of the workflow. Without a
breaking statement or
escape clause, it executes
forever.
Thursday, September 26, 13
Conditional Loops
A conditional loop (while,
do-while, for, foreach)
returns to a condition
check ($count < $max).
Until the condition
evaluates FALSE, the loop
will continue to execute
Thursday, September 26, 13
Diagramming Part Two
In your pair, find a section of a project that has some
significant looping and conditional logic (at least three
branches)
Individually, sketch a simple workflow diagram of the
logic; assemble a truth table if needed
Discuss differences in your diagrams and make a new
diagram and truth table for the logic to demonstrate
Thursday, September 26, 13
ASSIGNMENT 5.2
Loops and Conditionals
Thursday, September 26, 13
Create a file called "homework-5.2.md" in your "assignments"
workspace on Cloud 9
Find a section in your projects that has some decent looping and
branching code: at least five branches that you can diagram.
Copy and paste your example into your file and attempt to identify the
loop conditions with comments:
while ( $count < $max ) {
// while $count is less than $max
foreach ( $collection as $item ) {
// until there are no more $items in the $collection
Save your file, then git add, git commit -m "explain why" and git push
Thursday, September 26, 13

More Related Content

What's hot

SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for BeginnersAbdelhay Shafi
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteAl-Mamun Sarkar
 
Vlookup Description
Vlookup DescriptionVlookup Description
Vlookup DescriptionVijay Perepa
 
Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)Tech_MX
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQLRaajendra M
 
Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12Thuan Nguyen
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive dataAmrit Kaur
 
Forall & bulk binds
Forall & bulk bindsForall & bulk binds
Forall & bulk bindsNawaz Sk
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql StatmentsSHC
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionarynitamhaske
 
Oracle Collections
Oracle CollectionsOracle Collections
Oracle CollectionsTrendz Lab
 
Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Thuan Nguyen
 
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchOn if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchRakesh Sah
 
Marcs (bio)perl course
Marcs (bio)perl courseMarcs (bio)perl course
Marcs (bio)perl courseBITS
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variablessana mateen
 

What's hot (19)

SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Vlookup Description
Vlookup DescriptionVlookup Description
Vlookup Description
 
Introduction to perl_lists
Introduction to perl_listsIntroduction to perl_lists
Introduction to perl_lists
 
Linked list1
Linked list1Linked list1
Linked list1
 
Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)Symbol table design (Compiler Construction)
Symbol table design (Compiler Construction)
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQL
 
Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
Forall & bulk binds
Forall & bulk bindsForall & bulk binds
Forall & bulk binds
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Oracle Collections
Oracle CollectionsOracle Collections
Oracle Collections
 
7 stacksqueues
7 stacksqueues7 stacksqueues
7 stacksqueues
 
Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15Oracle - Program with PL/SQL - Lession 15
Oracle - Program with PL/SQL - Lession 15
 
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchOn if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
 
9
99
9
 
Marcs (bio)perl course
Marcs (bio)perl courseMarcs (bio)perl course
Marcs (bio)perl course
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variables
 

Viewers also liked (9)

Spanish verbs friends
Spanish verbs friendsSpanish verbs friends
Spanish verbs friends
 
Dig1108 Lesson 3
Dig1108 Lesson 3Dig1108 Lesson 3
Dig1108 Lesson 3
 
DIG1108 Lesson 4
DIG1108 Lesson 4DIG1108 Lesson 4
DIG1108 Lesson 4
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 
Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...Live virtual machine migration based on future prediction of resource require...
Live virtual machine migration based on future prediction of resource require...
 
Dig1108C Lesson 2
Dig1108C Lesson 2Dig1108C Lesson 2
Dig1108C Lesson 2
 
Dig1108 c lesson1
Dig1108 c lesson1Dig1108 c lesson1
Dig1108 c lesson1
 
DIG1108 Lesson 8
DIG1108 Lesson 8DIG1108 Lesson 8
DIG1108 Lesson 8
 
Separata protoracionalismo
Separata protoracionalismoSeparata protoracionalismo
Separata protoracionalismo
 

Similar to DIG1108 Lesson 5

Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat SheetLaura Hughes
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programmingTim Essam
 
Relational data model
Relational data modelRelational data model
Relational data modelSURBHI SAROHA
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.pptsoniya555961
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Mysqlppt
MysqlpptMysqlppt
MysqlpptReka
 
Basic iOS Training with SWIFT - Part 2
Basic iOS Training with SWIFT - Part 2Basic iOS Training with SWIFT - Part 2
Basic iOS Training with SWIFT - Part 2Manoj Ellappan
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPeterlqELawrenceb
 
98765432345671223Intro-to-PostgreSQL.ppt
98765432345671223Intro-to-PostgreSQL.ppt98765432345671223Intro-to-PostgreSQL.ppt
98765432345671223Intro-to-PostgreSQL.pptHastavaramDineshKuma
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxIsaac9LjWelchq
 
Perl programming language
Perl programming languagePerl programming language
Perl programming languageElie Obeid
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxcarliotwaycave
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)monikadeshmane
 
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxAssg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxfestockton
 

Similar to DIG1108 Lesson 5 (20)

Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programming
 
Relational data model
Relational data modelRelational data model
Relational data model
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
stack.ppt
stack.pptstack.ppt
stack.ppt
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Perl
PerlPerl
Perl
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Basic iOS Training with SWIFT - Part 2
Basic iOS Training with SWIFT - Part 2Basic iOS Training with SWIFT - Part 2
Basic iOS Training with SWIFT - Part 2
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docx
 
98765432345671223Intro-to-PostgreSQL.ppt
98765432345671223Intro-to-PostgreSQL.ppt98765432345671223Intro-to-PostgreSQL.ppt
98765432345671223Intro-to-PostgreSQL.ppt
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
 
Perl programming language
Perl programming languagePerl programming language
Perl programming language
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
 
Les13
Les13Les13
Les13
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Les12
Les12Les12
Les12
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)
 
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxAssg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
 
Cs341
Cs341Cs341
Cs341
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

DIG1108 Lesson 5

  • 1. INTRO TO SERVER SIDE PROGRAMMING Lesson Five Thursday, September 26, 13
  • 2. Lists and Dictionaries In computer science, a list (or sequence) is an abstract data type that implements an ordered collection of values. Each instance of a value on a list is usually called an item, entry or element of the list, and if the same value appears multiple times in the list, each is considered a distinct item of the list. An associative array (or dictionary) is an abstract data type composed of a collection of key/value pairs, such that each key appears at most once in the collection. Pairs can be added or removed, and values can be modified or retrieved based on the associated key. Thursday, September 26, 13
  • 3. What's The Difference? A list is always ordered, can usually return elements or items by numeric index(starting at zero), and might not allow modification of values. A decent implementation of a list should provide specific operations for adding and removing elements to enable them to be used: push - append to the end(or tail) of the list pop - remove from the tail of the list queue(unshift) - append to the beginning(or head) of the list dequeue(shift) - remove from the head of the list A hash is usually not immutable and may be indeterminately ordered. Values can usually be altered. Thursday, September 26, 13
  • 4. Arrays An array type is a data type that is meant to describe a collection of values or variables, each selected by one or more indices(keys) tha can be computed at run-time of the program. By default, the array type in PHP generates computed, numerical indices, starting with zero, to make a list: var_dump(array( 'one', 'two', 3, 4, 4.1, 4.2 )); $list = array(); $list[] = 'one'; $list[] = 'two'; The value for the key can also be specified as any scalar literal (neither array, object nor resource), often a string var_dump(array( 'one' => 1, 2 => 'two' )): $list[4] = 'four'; $list['five dot one'] = 5.1; Thursday, September 26, 13
  • 5. Array Tricks PHP relies heavily on arrays, so there are a lot of array- specific functions, like to use an array as a queue or stack array_unshift(), array_shift() - append to and remove from head array_push(), array_pop() - append to and remove from tail PHP arrays have an "internal position" pointer that can be used as an iterator: current(), key() - return the current element or key next(), prev(), end(), reset() - advance forward or back each() - return the current key and value and advance the pointer Thursday, September 26, 13
  • 6. Even More Array Tricks array_merge() - merge two or more arrays array_slice() - remove an array section array_splice() - insert or replace a section count(), sizeof() - calculate length array_fill(), array_pad(), range() - generate values str_split(), explode(), implode(), join() - array to string Thursday, September 26, 13
  • 7. ASSIGNMENT 5.1 Find Some Lists and Arrays Thursday, September 26, 13
  • 8. Lists of Lists Open Github and Cloud 9 Look through your forked projects for examples of lists and dictionary definitions and methods Copy adn paste your examples into a file named "homework-5.1.md" with code delimiters as needed Write comments identifying the lists, keys, indexes and other list and dictionary pieces discussed Save, add and commit, then push to Github when done Thursday, September 26, 13
  • 10. Control Flow Statements Control Flow - refers to the order in which the individual statements, instructions or function calls of an imperative or declarative program are executed or evaluated. Execution results in a choice being made as to which of two or more paths should be followed. Types of Control Flow statements: continuation at a different statement (unconditional branch or jump) execute statements only if some condition is met (conditional branch) execute statements until some conditional is met(loop, conditional branch) execute defined statements and return (sub/co-routines, continuations)s stop executing statements (unconditional halt) Thursday, September 26, 13
  • 11. Loops A loop is a sequence of statements which is specified once but which may be carried out several times in succession, a specified number of times or indefinitely Specific number of times: for ( $count = 0; $count < $max; $count++ ) do_something(); Once per each item in a collection(array): foreach ( $collection as $item ) do_something(); foreach ($collection as $key => $value ) do_something(); Until some condition is met: while ( $condition == true ) do_something(); do something(); while ( $condition ); Indefinitely(infinitely): while ( true ) do_something(); do something(); while ( true); Thursday, September 26, 13
  • 12. Infinite Loops An unconditional(or infinite) loop returns to a fixed point in the diagram, usually the top of the workflow. Without a breaking statement or escape clause, it executes forever. Thursday, September 26, 13
  • 13. Conditional Loops A conditional loop (while, do-while, for, foreach) returns to a condition check ($count < $max). Until the condition evaluates FALSE, the loop will continue to execute Thursday, September 26, 13
  • 14. Diagramming Part Two In your pair, find a section of a project that has some significant looping and conditional logic (at least three branches) Individually, sketch a simple workflow diagram of the logic; assemble a truth table if needed Discuss differences in your diagrams and make a new diagram and truth table for the logic to demonstrate Thursday, September 26, 13
  • 15. ASSIGNMENT 5.2 Loops and Conditionals Thursday, September 26, 13
  • 16. Create a file called "homework-5.2.md" in your "assignments" workspace on Cloud 9 Find a section in your projects that has some decent looping and branching code: at least five branches that you can diagram. Copy and paste your example into your file and attempt to identify the loop conditions with comments: while ( $count < $max ) { // while $count is less than $max foreach ( $collection as $item ) { // until there are no more $items in the $collection Save your file, then git add, git commit -m "explain why" and git push Thursday, September 26, 13