New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update loop lession so that the first example follows lesson #674

Open
wants to merge 1 commit into
base: gh-pages
from

Conversation

Projects
None yet
4 participants
@krisp

krisp commented Dec 6, 2017

During my instructor demo of this lesson, we noticed that the material at the beginning of the lesson does not correspond to the early examples. I've added an example that goes with the top of the lesson.

Update loop lession so that the first example relates to the first pa…
…rt of the lesson

During my instructor demo of this lesson, we noticed that the material at the beginning of the lesson does not correspond to the early examples. I've added an example that goes with the top of the lesson.
@cdarabos

This comment has been minimized.

cdarabos commented Mar 15, 2018

This is a great improvement on the existing example. I'd add a definition of the variable. The word variable appears first at line 77, and I suspect people might not immediately see that we refer to "filename".

Maybe something along these lines could replace lines 76-78:

===
Each time the loop runs is called an iteration. At the first iteration, the first item in the list is assigned variable (called "filename" in the example), and the commands inside the loop are executed. An iteration is over once the last command in the loop is executed. Before the next iteration starts, the next item in the list, if any, is assigned to the variable. If we have executed the last command in the last iteration (i.e. the variable contained the last value in the list), the loop is exited and the code below the loop is executed.

@colinmorris

This comment has been minimized.

Contributor

colinmorris commented Mar 19, 2018

Sorry that this PR seems to have fallen through the cracks for a while. (Thanks for bumping, @cdarabos )

A surface problem with this change is that it renders a later part of the episode ("Going back to our original file copying problem, we can solve it using this loop:...") redundant.

But more fundamentally, I don't think I like throwing the solution to the backup problem at them right away. I think there are some execution problems with this part of the episode as it currently exists, but I like the overall approach it takes of starting with a relatively simple for loop, and building up to the final goal (adding pieces as we go about concatenating with variables and using wildcards in the loop).

@sthiede

This comment has been minimized.

sthiede commented Oct 2, 2018

Hi! I also noticed that the example did not follow the problem that was set up during my instructor demo lesson as well - it was awkward to teach. In teaching for loops in R to a class recently, I did find it helpful to show a task that would take a long time without loops and then immediately show how to do it in a loop - to give the learners a motivation as to why you would want to use a loop.

Here's my suggestion:

  1. Show a task that would be tedious to do without a for loop

  2. Show a simple for loop anatomy in an image or text (like this):
    for name in list_of_names;
    do an action;
    done

  3. Use for loop to solve simple tedious task (as in 1)
    Note: The current simple for loop example could cause some confusion because you could also use wildcards to do the same thing - decreasing the motivation to use a for loop: head -n 3 *.dat

  4. As before -- Set up the complex example - we want to copy many files in a directory and save them with a new name original-name.dat.

  5. As before -- show the error that you get if you try to use wildcards (Side note, I get a different error than the one in the current lesson)

  6. Clarify in words that "During this lesson, we will learn how to solve this with a for loop"

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment