Skip to content

Update to logic lesson to prevent unpassable error #527

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions R_Programming/Logic/lesson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

- Class: cmd_question
Output: "You can use the `&` operator to evaluate AND across a vector. The `&&` version of AND only evaluates
the first member of a vector. Let's test both for practice. Type the expression TRUE & c(TRUE, FALSE, FALSE)."
logical vectors of length-one. Let's test both for practice. Type the expression TRUE & c(TRUE, FALSE, FALSE)."
CorrectAnswer: "TRUE & c(TRUE, FALSE, FALSE)"
AnswerTests: omnitest(correctExpr='TRUE & c(TRUE, FALSE, FALSE)')
Hint: "Now to see how the AND operator works with a vector, type:
Expand All @@ -143,21 +143,21 @@
statement as c(TRUE, TRUE, TRUE) & c(TRUE, FALSE, FALSE).

- Class: cmd_question
Output: "Now we'll type the same expression except we'll use the `&&` operator. Type the expression TRUE && c(TRUE, FALSE, FALSE)."
CorrectAnswer: "TRUE && c(TRUE, FALSE, FALSE)"
AnswerTests: omnitest(correctExpr='TRUE && c(TRUE, FALSE, FALSE)')
Output: "Now we'll try the `&&` operator. Type the expression TRUE && TRUE."
CorrectAnswer: "TRUE && TRUE"
AnswerTests: omnitest(correctExpr='TRUE && TRUE')
Hint: "As you'll see, the && version of AND works differently. Type:
TRUE && c(TRUE, FALSE, FALSE)"
TRUE && TRUE"

- Class: text
Output: "In this case, the left operand is only evaluated with the first member
of the right operand (the vector). The rest of the elements in the vector
aren't evaluated at all in this expression."
Output: "In this case, the left and right operands are length-one logical vectors.
Since R 4.3.0, if provided vectors of length greater than one, `&&` produces an error. In earlier
R versions the first elements of the LHS and RHS would be evaluated against each other."

- Class : text
Output: The OR operator follows a similar set of rules. The `|` version of OR
evaluates OR across an entire vector, while the `||` version of OR only evaluates
the first member of a vector.
evaluates OR across an entire vector, while the `||` version of OR only accepts
length-one logical vectors.

- Class : text
Output: An expression using the OR operator will evaluate to TRUE if the left
Expand All @@ -174,11 +174,11 @@

- Class: cmd_question
Output: "Now let's try out the non-vectorized version of the OR operator. Type the
expression TRUE || c(TRUE, FALSE, FALSE)."
CorrectAnswer: "TRUE || c(TRUE, FALSE, FALSE)"
AnswerTests: omnitest(correctExpr='TRUE || c(TRUE, FALSE, FALSE)')
expression TRUE || TRUE"
CorrectAnswer: "TRUE || TRUE"
AnswerTests: omnitest(correctExpr='TRUE || TRUE')
Hint: "As you'll see the || version of OR is not vectorized. Type:
TRUE || c(TRUE, FALSE, FALSE)"
TRUE || TRUE"

- Class : text
Output: "Logical operators can be chained together just like arithmetic operators.
Expand Down