Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 32: Characters and Strings


Same partners!

Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Questions

What encoding does DrRacket use?

Unicode.

Could you explain this part of the reading? It makes sense that you can compare characters together to see which comes first in integer collation, but I don't understand how that concept can apply to entire strings.

Strings can be compared for "lexicographic order", the extension of alphabetical order that is derived from the collating sequence of the local character set. Once more, Scheme provides both case-sensitive and case-insensitive versions of these predicates: string<?, string<=?, string=?, string>=?, and string>? are the case-sensitive versions, and string-ci<?, string-ci<=?, string-ci=?, string-ci>=?, and string-ci>? the case-insensitive ones.

This is mostly what you expect for alphabetical order. Say we have two strings, which I'll call string1 and string2.

If the collating sequence number of the first letter of string1 is smaller than the collating sequence number of the first letter of string2, string1 precedes string2 lexicographically.

If the collating sequence number of the first letter of string1 is larger than the collating sequence number of the first letter of string2, string1 follows string2 lexicographically.

If the two collating sequence numbers are equal, we go on to the next character and repeat that whole process again.

If we run out of letters in one string before running out of letters in the other string, the first string is lexicographically first.

It's basically "dictionary order".

Questions on letrec and named let

Students are too overwhelmed to have any questions.

Brief overview of reading

Nevermind, Sam, we think we understand it.

Lab

Why is the last parameter to substring the index after the last character that substring extracts?

  1. It means that we can use the same value for the end of one substring and the start of the next substring.

  2. It means that we can use (string-length str) as the last parameter to substring when we want "everything until the end".

Something I'd forgotten about Scheme

    > (substring "Hello" 1)
    "ello"

Debriefing

How did you make "???" using list->string?

(list->string (list #\? #\? #\?))
(list->string (make-list 3 #\?))

If make-string did not exist, how would you define it?

(define make-string
  (lambda (num char)
    ...))

How did you write string-sum?