Functional Problem Solving (CSC 151 2014F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Same partners!
Overview
letrec and named let.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>=?, andstring>?are the case-sensitive versions, andstring-ci<?,string-ci<=?,string-ci=?,string-ci>=?, andstring-ci>?the case-insensitive ones.This is mostly what you expect for alphabetical order. Say we have two strings, which I'll call
string1andstring2.If the collating sequence number of the first letter of
string1is smaller than the collating sequence number of the first letter ofstring2,string1precedesstring2lexicographically.If the collating sequence number of the first letter of
string1is larger than the collating sequence number of the first letter ofstring2,string1followsstring2lexicographically.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".
letrec and named letStudents are too overwhelmed to have any questions.
Nevermind, Sam, we think we understand it.
Why is the last parameter to substring the index after the last character
that substring extracts?
It means that we can use the same value for the end of one substring and the start of the next substring.
It means that we can use
(string-length str)as the last parameter tosubstringwhen we want "everything until the end".
Something I'd forgotten about Scheme
> (substring "Hello" 1)
"ello"
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?