Assignment 7 FAQs, Clarifications and Corrections

FAQs

  1. Q: It seems like you've told us a dozen different ways to save typing in the edit/run cycle for Ruby, but I don't like any of them. Do you have a 13th?

    A: Recently I've been encouraging the addition of a method named "r" (for reload) at the end of each .rb file. For example, in re.rb, have this:

    def r
        load "re.rb"
    end
    
    You'll still to load the file once by hand, either with irb -r ./re.rb or load "re.rb", but once that's done, just type r to load the latest.

    Hint: Just type r! (I've seen a few students hit up-arrow until they get back to the r and then hit ENTER. I'm not kidding!)

  2. Q: Is there a form of diff that will put differing lines close to each other?
    A: Try diff -u. As Using the Tester points out, a tester diff is followed with the names of the files diff'd (underlined):
    ...
    Test: 'ulimit -t 2; ruby a7/re1.rb sen < a7/re.sen': FAILED
    Differences (expected/actual):
    *** a7/master/tester.out/sen.out.01     2016-03-25 12:57:28.000000000 -0700
    --- tester.out/sen.out.01       2018-04-03 01:27:37.094132320 -0700
    ...not shown...
    
    Files diffed:
    a7/master/tester.out/sen.out.01 tester.out/sen.out.01
    
    Let's tack those names onto diff -u:
    $ diff -u a7/master/tester.out/sen.out.01 tester.out/sen.out.01
    --- a7/master/tester.out/sen.out.01     2016-03-25 12:57:28.000000000 -0700
    +++ tester.out/sen.out.01       2018-04-03 01:27:37.094132320 -0700
    @@ -1,7 +1,7 @@
     Yes: "X."
     Yes: "I shall test this."
     Yes: "It worked!?"
    -Yes: "It worked?!"
    +No: "It worked?!"
     Yes: "In this problem you are to write four methods."
     Yes: "Is THIS a valid sentence?"
     Yes: "That is valid!"
    
    Yes, there should be a tester option to select the type of diff. Maybe I'll add that if there's some clamoring for it.

Clarifications

None yet!

Corrections (fixed on the web)

  1. In re.rb, smg.txt was cited as smb.txt.
  2. In re.rb, there was "72" instead of "72 hours".
  3. In vstring.rb, the example of resolution .new was omitted: s = ReplString.new("abc",10)
  4. In the vstring.rb write-up, on page 16 of the printed copies, an HTML markup error led to only a fragment of the output for cat a7/mkfile.rb being shown. The printed write-ups have this:
    $ cat a7/mkfile.rb
    prog = <&1`
    puts "Program output: (#{result.size} bytes)", result
    
    It should be this:
    $ cat a7/mkfile.rb
    prog = <<X
    public class hello {
        public static void main(String args[]) {
            System.out.println("Hello, #{ARGV[0]}!");
            }
        }
    X
    # IMPORTANT: That X just above MUST BE IN THE FIRST COLUMN!
    
    f = File.new("hello.java","w")
    f.write(prog)
    f.close
    result = `bash -c "javac hello.java && java hello" 2>&1`
    puts "Program output: (#{result.size} bytes)", result
    
  5. On page 15 of the optab write-up, just below cat checkop.hs, the following line was duplicated:
    >> result = `bash -c "ghci -ignore-dot-ghci < checkop.hs" 2>&1`
    
  6. The type/expression table at the bottom at the bottom of page 16 should have new Object() instead of just new Object