if
Use if
expressions
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
value | output |
---|---|
#f | B |
#t | A |
Use nested if
expressions
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
expression | output |
---|---|
(if #t (if #t 65 67) 67) | A |
(if #f 67 (if #f 67 66)) | B |
Use deeply nested if
expressions
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
expression | output |
---|---|
(if #t (if #t (if #t 65 67) 67) 67) | A |
(if #f 67 (if #f 67 (if #f 67 66))) | B |
Use a one-sided if
expression
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
value | output |
---|---|
#f | |
#t | A |
Use sequenced if
expressions
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
value1 | value2 | value3 | output |
---|---|---|---|
#t | #t | #t | AAA |
#t | #t | #f | AAB |
#t | #f | #t | ABA |
#t | #f | #f | ABB |
#f | #t | #t | BAA |
#f | #t | #f | BAB |
#f | #f | #t | BBA |
#f | #f | #f | BBB |
Use deeply nested if
expressions
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
value1 | value2 | value3 | output |
---|---|---|---|
#t | #t | #t | AAA |
#t | #t | #f | AAB |
#t | #f | #t | ABA |
#t | #f | #f | ABB |
#f | #t | #t | BAA |
#f | #t | #f | BAB |
#f | #f | #t | BBA |
#f | #f | #f | BBB |
Use sequenced if
expressions in a nested if
expression
Given a file named “main.scm” with:
When I successfully run scheme main.scm
Then the stdout should contain exactly “<output>”.
Examples
value1 | value2 | value3 | output |
---|---|---|---|
#t | #t | #t | AAA |
#t | #t | #f | AAB |
#t | #f | #t | ABA |
#t | #f | #f | ABB |
#f | #t | #t | BAA |
#f | #t | #f | BAB |
#f | #f | #t | BBA |
#f | #f | #f | BBB |