Skip to main content

Flashcards for week 4

Due: 8 p.m. on Wednesday, 13 February 2019

Create ten questions and answers on topics we have explored in the past week (e.g., Regular expressions and lists).

Send your questions and answers to rebelsky@grinnell.edu.

Title your email CSC 151.01 Flashcards for week 4 (YOUR NAME).

Include your questions and answers in the body of the email.


Submitted questions

Here you can find some of the questions and answers that have been submitted so far (at least those that Sam had time to add).

Big picture

What purpose do regular expressions serve?
What purpose do lists serve?
How is the position of an element in a list or a character in a string different in Racket than how we would normally count it?

List creation

What are three ways to make a new list?
Does (make-list 4 2) create the list '(4 2)?
What does a tick before parentheses do?
How does range present information if called on one parameter?
How does range present information if called on two parameters?

Other basic list operations

What type does index-of return?
What type is returned by (list-ref lst i)?
What does the procedure list-ref do?
What’s the difference between take and drop?
What is (list 1 (list + 2 3) 4)?
What if I want the + as a symbol, rather than a procedure?
What is (make-list 7 5)?
What is (range 2)?

Compound list operations

What kinds of parameters does reduce take?
Do we expect the same results from (reduce - (list 23 5 -7 2)) every time?
How do you apply a binary procedure to a single list?
What does the sort procedure do?
What procedure counts the occurrences of a value in a list?
What does map do?
If we have (define numbers (list 2 4 6 8)) and (reduce max numbers), what is the output?
Describe when you should use the map procedure.
What is the output (map string-length (list “Hello” “How” “Are” “You” “Sam”))

Regular expressions - patterns

What do the periods represent in this regular expression: "px"...ck"?
What is a “set”?
How do you represent a set?
What does #px"[a-z]" mean?
If I want to one of multiple different pattern what can I use?
What regular expression might you use for “a followed by at least two bs?
What is the difference between a star (*) and a plus sign (`+1) in a regular expression?
What is the difference between #px"aeiou" and #px"[aeiou]" in a regular expression?
What is \\W?
What is the difference between \\s and \\S?
Why do we use two backslashes rather than one when we use backslash patterns in strings?
For “backslash patterns” what are \d, \D, \w, \W, \s, and \S?
What are the roles of parentheses in regular expressions?

Regular expressions - procedures

What is the difference between regexp-match* and regexp-match?
What is the output of (string-split "The person runs around for fun" #px"[aeiou]")?
What is the difference between regexp-match* and regexp-replace?
What is the difference between #px"^[a-z]" and #px"[^a-z]"?
What does "\\1\\1" mean in (regexp-replace* #px"(a|b|c)" "a a a b b c" "\\1\\1")?

Strings

What type does string-ref return?
How can I turn a string into a number?
How many characters does "\n" count for in a string?
How many characters does "/n" count for in a string?
How do I represent an empty string?
Why might I get an error when I append “%” to my average function?
Can you append multiple strings at a time?

Miscellaneous

Semicolons can be used in the definitions pane to create a comment. What else can be used to create a (probably longer) comment?
Why should we document our code?
What do we expect from (> (floor 2.5) (ceiling 2.5))?
What is (length (string-split "I love to drink coffee"))?
How can one take a ratio and return a number in terms of decimals?
What type of input does file->string take?