teaching machines

CS 330 Lecture 19 – A Type Dichotomy

March 13, 2015 by . Filed under cs330, lectures, spring 2015.

Agenda

TODO

For a 1/4 sheet participation point, compose a midterm question about some topic we’ve discussed so far this semester. Follow these guidelines in forming your question:

  1. The question should require cognitive processes to answer. Merely recalling trivia does not. You can look at exams from past semesters under the Teaching tab.
  2. The question should be short and accessible.
  3. The question relate to the course objectives, which are:
    • Recognize and exploit the strengths of three major programming paradigms: imperative, functional, and object-oriented.
    • Reason about the strengths and weaknesses of the several mainstream type systems.
    • Weigh the costs and benefits of static and dynamic decision making.
    • Design and develop tools for recognizing and interpreting domain-specific languages.
    • Develop code in languages with addressable and dynamically-allocated memory.

Share your question on Piazza, under folder midterm.

Code

z.c

void a() {
  char c = 'z';
  int i = c;
}

endian.c

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
  int i = 1;
  char *b0 = (char *) &i;
  char *b3 = b0 + 3;
  printf("Big endian: %d\n", *b3 == 1);
  printf("Little endian: %d\n", *b0 == 1);
  return 0;
}

printer.cpp

#include <iostream>
#include <vector>

void print(const std::vector<int>& nums) {
  /* for (std::vector<int>::const_iterator i = nums.begin(); i != nums.end(); ++i) { */
  for (auto i : nums) {
    std::cout << "*i: " << i << std::endl;
  }
}

int main(int argc, char **argv) {
  std::vector<int> nums {12, 13, 18}; 
  print(nums);
  return 0;
}

Haiku

on pursuing the best
Ms. Right won’t be found
Not while you are Mr. Wrong
Try changing your name