Warning This class is being recorded (for those who can’t be here today).
Getting started
For the future: I’m happy to reserve a (somewhat random) seat at the front of the classroom who need a front seat as an adjustment or accommodation. Just let me know.
Approximate overview
Here’s the approximate distribution of concerns as of 5:00 p.m. yesterday.
These are not unreasonable concerns. But I’d like to address some of them, particularly time and workload.
My least favorite comment, and one I thought I should respond to:
I have heard many negative opinions on CSC-151 such as the choice of language and the way it’s being taught.
+ and * can take more than two parameters.string-split in the Q&A section.What is that backwards apostrophe you keep typing?
It’s a “backtick”. When the eboard gets formatted, the text surrounded by backticks gets presented in a monospace font family, making it look more like computer code.
Will the readings always be this long?
Generally, you’ll only have one or two, rather than four or five. We ask for a bit more reading during the first week.
The majority of you spent between one and two hours. In some of the longer cases, it seems like you were also counting the syllabus reading and/or you attempted to write out answers to all of the self checks.
Keep me posted if you regularly spend more than an hour. We can look at ways to make you more efficient.
Should we try things in Racket as we go?
I wasn’t expecting you to do so for the first readings, but it’s generally a good idea.
Do we have to submit all of the self checks?
Nope. Only the ones with double daggers. You should think through the rest, though.
What’s the difference between an argument and a parameter?
In most uses, nothing.
To some computer scientists, parameters are for function definitions and arguments are for function calls. E.g., “square is a function that takes one parameter, x”. “Square the argument 5.”
What’s the difference between an operator and a procedure?
In some languages, where you write them. For example, in C, you’d write
double(5)and5 + 5.
In Scheme; not much. We write
(double 5)and(+ 5 5).
How are parameters related to variables?
“parameter” is another way to say “argument”. Like variables, parameters and arguments name values. However, parameters are “inputs” to a function, while variables are things we compute/name along the way.
What’s the difference between a function and a procedure?
In Racket, nothing.
In some languages, functions return values and procedures do not.
What type is a circle?
It’s an image. As you’ll learn on Friday, we can do a variety of things with images.
In Racket, should 3/4 be written as (/ 3 4) or (/ 4 3)?
Either as
3/4or as(/ 3 4)
And for subtraction, should 3-4 be written as (- 3 4) or (- 4 3)?
(- 3 4)
What is the meaning of the 2 quotation marks in the rear of the
procedure (string-split "string" "").
""is “an empty string”; that is, a sequence of zero letters.
Why is the first value of the output list in blue?
Because our text formatter is stupid.
What does (string-split "Snicker snack" "ck") mean?
Split the string (sequence of characters)
"Snicker snack"at every instance of the sequence"ck". So we should get two or strings out of it:"Sni","er sna", and perhaps the empty string.
Is a sentence considered a list of strings?
We can choose multiple ways to represent sentences. We could use a list of strings. We could also use a single string with lots of spaces (and a period, exclamation mark, or question mark).
Are there tricks for navigating DrRacket faster?
Ctrl-R does “Run”
Ctrl-uparrow or Esc-P brings back the prior command.
Ctrl-downarrow or Esc-N goes forward a command again.
Could you give more examples of how we describe procedures?
Not right now. If things don’t make sense after today’s lab, ask again.
Could you explain “list of values” as a type?
Some procedures return multiple values, which we say are grouped into a list. For example,
string-splitreturns a list of strings.
Other procedures can take those lists as input. For example,
lengthtakes a list as an input and gives you the number of elements in the list.
The map procedure seems cool. Can we talk more about it?
Sure. Next week. Maybe the week after.
What version of Racket should we use?
8.3, if possible.
What’s the difference between (string-length "a bb ccc dd e") and
(map string-length (string-split "a bb ccc dd e"))?
string-lengthtakes a string as a parameter and counts the number of characters (things you would type, including the spaces).
As you’ve seen,
string-splitgives you a list of strings.
mapwithstring-lengthworks with each element of the list.
I’ll try to demo this in DrRacket.
Can I nest parenthesized expressions?
Yup. As much as you want, as long as you follow the “open paren, function/operation, arguments, close paren” model for each parenthesized expression.
What’s wrong with writing (5)?
5 isn’t a function/operation.
Notes:
Questions
Think/Pair/Share
Getting students into card groups was chaos. I intentionally don’t give an algorithm, and it shows. What’s a better algorithm?
We skipped this to make sure we had sufficient time for labs.
It’s in the schedule. Each person will do this separately, with the other person helping.
If Firefox doesn’t start, we need to edit the launcher to use
firefox instead of firefox-esr %u.
Nope, there wasn’t time.
The origin of the short and long versions. My colleagues who first taught the course wrote the long versions (or at least the original versions of the long versions). When I started teaching, I decided you might do better with short instructions. But it’s a nice example of different ways of thinking about writing algorithms/instructions.
I see that many of you have three screens (our main screen plus two laptops). Please do your work on the MathLAN workstation and just use your laptop for bringing up the lab/reference materials.