nature-of-code / Nature-of-Code-Website-Archive

Repo for web files for nature of code
https://noc-processing-archive.netlify.app/
111 stars 21 forks source link

A minor typo from book #24

Closed vinjohn closed 1 year ago

vinjohn commented 8 years ago

From Section 8.6 L-systems, Chapter 8, when describing FG+-[] by code,

for (int i = 0; i < sentence.length(); i++) {

  // Looking at each character one at a time
  char c = sentence.charAt(i);

  //[full] Performing the correct task for each character.
  // This could also be written with a “case” statement,
  // which might be nicer to look at, but leaving it as an
  // if/else if structure helps readers not familiar with case statements.
  if (c == 'F') {
    line(0,0,len,0);
    translate(len,0);
  } else if (c == 'F') {
   translate(len,0);
  } else if (c == '+') {
    rotate(theta);
  } else if (c == '-') {
    rotate(-theta);
  } else if (c == '[') {
    pushMatrix();
  } else if (c == ']') {
    popMatrix();
  }

I could be wrong but I think it should be if(c=='F'){}else if(c=='G')? After all it's just minor mistake, readers can easily infer from the context.

shiffman commented 8 years ago

Yes, this is a mistake, can you post at https://github.com/shiffman/The-Nature-of-Code/issues and then close this one? (It's confusing I realize but this natureofcode.com repo is for website bugs but the book content itself is generated at the other one.)

shiffman commented 1 year ago

This has been updated in the 2nd edition! https://github.com/nature-of-code/book-website-2nd-edition!