From while to for: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "<slidy theme="aa" /> Importance / Use of Scope == from while... == <source lang="javascript"> c=0; while (c<10) { ctx.fillRect(0, c*10, 10, 10); c++; } </source> == ... t...")
 
Line 44: Line 44:


A [[wikipedia:Stack (abstract_data_type)|stack]] is an often used idea/data structure. It's based on a system used in cafeterias  where food trays could be "pushed on", and "popped off" a spring loaded system for use.
A [[wikipedia:Stack (abstract_data_type)|stack]] is an often used idea/data structure. It's based on a system used in cafeterias  where food trays could be "pushed on", and "popped off" a spring loaded system for use.
http://s.ecrater.com/stores/242163/4f24ed6ed9ebd_242163n.jpg

Revision as of 11:30, 1 October 2012

<slidy theme="aa" />

Importance / Use of Scope

from while...

c=0;
while (c<10) {
  ctx.fillRect(0, c*10, 10, 10);
  c++;
}

... to for

for (c=0; c<10; c++) {
  ctx.fillRect(0, c*10, 10, 10);
}

from while to for

c=0;
while (c<10) {
  ctx.fillRect(0, c*10, 10, 10);
  c++;
}

for (c=0; c<10; c++) {
  ctx.fillRect(0, c*10, 10, 10);
}

translate, rotate

https://developer.mozilla.org/en-US/docs/Canvas_tutorial/Transformations

stack

A stack is an often used idea/data structure. It's based on a system used in cafeterias where food trays could be "pushed on", and "popped off" a spring loaded system for use.

4f24ed6ed9ebd_242163n.jpg