EBoard 13: Files and regular expressions, continued

Approximate overview

  • Administrative stuff [10 min]
  • Regular expressions, reviewed [20 min]
  • Lab [50 min]

Administrative stuff

Introductory Notes

  • Same partners and places as Monday. (Agh! Remembering is hard.)
  • Happy Friday!
    • Potentially happy something else.
  • Warning! It’s Friday the 13th (class)!
  • Pop quiz (and much more) to be returned Monday. (I hope.)
  • Advance warning: If you miss three or more LAs, I will ask you to meet with me to go over them.
  • Don’t forget to use the evening tutors.
  • Don’t forget to use my office hours (or suggest other meeting times).
  • Don’t forget to DM me.

Friday PSA

  • You’re awesome.
  • Keep yourself that way.
  • Moderation!
  • Consent is ESSENTIAL!
  • Remember: People care about you.

Upcoming activities

Events

  • Visit the CS table at the majors fair today, 11:30-12:50 JRC 1st.
    • Remember, you should refer to the JRC as “Joe’s Quarter”
  • Grinnell Singers Saturday 7:30 in Sebring-Lewis.
  • Mentor Session Sunday 4:00 p.m. in the CS commons.
  • Pioneer Weekend introductory talk, 7:00 p.m. Friday, October 1.
  • Pioneer Weekend, October 1–3.
    • Yes, I agree that Pioneer Weekend should be renamed.
    • My Tutorial suggested that we should be the “Gremlins”

Other good things

  • Women’s volleyball today at home. 7:00 p.m.
  • Women’s soccer Saturday at home. 11:00 a.m.
  • Women’s volleyball Saturday at home. 1:00 p.m.
  • GSO Concert Saturday at 2:00 pm in Sebring-Lewis
  • Men’s soccer Saturday at home. 1:30 p.m.

Upcoming work

Q&A

Is there a way to combine ranges with Rex’s?

Yes.

(rex-any-of (rex-char-range #\a #\z) (rex-char-range #\A #\Z))

Regular Expressions, review

Regular expressions give you a somewhat different way of thinking about computation. It’s “match this pattern” rather than “Here’s how we match that pattern.”

Lab, Continued

Introductory comments

If you finish lab early, work on the third mini-project. You may work separately or together.

Comments during lab

“Not alphabetic”

“Not alphabetic” is a bit complicated. rex-char-antiset is the right intuition. But you should only do one call to rex-char-antiset. Why? Consider the following.

(rex-any-of (rex-char-antiset "a") (rex-char-antiset "b"))

Does that match the string "a"? Yes! Why? Because although (rex-char-antiset "a") doesn’t match, (rex-char-antiset "b") does.

And yes, that means you probably have to write something like (rex-char-antiset "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Blame the people who designed the Rex library. Whoops, that’s me.

Style

I’ve seen the following a few times.

(define whitespace
  (rex-any-of (rex-string (string #\space))
              (rex-string (string #\newline))
              (rex-string (string #\tab))))

(define whitespace-sequence
  (rex-repeat (rex-any-of (rex-string (string #\space))
                          (rex-string (string #\newline))
                          (rex-string (string #\tab)))))

Why don’t I like that definition of whitespace-sequence?

Use your names!

Consider the following …

(define book-characters (file->chars "pg1260.txt"))
(define first-20-characters (take (file->chars "pg1260.txt") 20))

Why don’t I like that?