Date: Wed, 07 November 2001 3:35 PM (CST) --- Temperature 71 degrees From: Mark Jacobson To: 810-080-01@uni.edu, 810-080-02@uni.edu Subject: URL for lab stuff... Hi discrete students, See the http://www.cns.uni.edu/~jacobson/080/lab080.html and the http://www.cns.uni.edu/~jacobson/c080.html page that links to it. We will do some different computer things on Friday, but the more you look over your September 10th handout and the other resources that are available from the http://www.cns.uni.edu/~jacobson/080/lab080.html, lab class, the better off you will be. The two pages of your textbook to study to review today's class are: Page 223 Definition 5.3 and Definition 5.4 Get the terms function, mapping, image, preimage, domain, codomain, and range down. Page 251 Definition 5.18 for composition of functions. If f:A -------> B and g:B ------> C, we define the composite function, which is denoted g o f:A -----> C, by (g o f)(a) = g(f(a)), for each a elementOf A. The C++ program that we looked at today had a while loop and it looks like this: [jacobson@cowboy ~]$ more f.cpp #include void main() { int n; while (cin >> n) { cout << n*n << endl; } } [jacobson@cowboy ~]$ g++ f.cpp -o f.exe [jacobson@cowboy ~]$ ls -l f.cpp -rw-r--r-- 1 jacobson cns_fac 107 Nov 7 11:47 f.cpp [jacobson@cowboy ~]$ ls -l f.exe -rwxr-xr-x 1 jacobson cns_fac 12966 Nov 7 14:49 f.exe Notice that the function g++ mapped the C++ program f.cpp to the machine language program f.exe, which is in a file of size 12,966 bytes!!!! f.cpp size = 107 bytes source code f.exe size = 12,966 bytes object code f.cpp ---------------------------> f.exe g++ compiler function Compilers are just functions that map from the domain of C++ or or Pascal or Ada or Java or Lisp or Visual Basic to the language of the machine you are compiling for. f.cpp ---------------------------> f.exe g++ source object code code C++ machine language programs programs (Intel Pentium or domain Sun workstation or whatever processor machine language) 2 [jacobson@math-cs ~]$ ./f.exe f(x) = x f(2) = 4 f(4) = 16 2 f(6) = 36 4 4 16 6 36 [jacobson@math-cs ~]$ ./f.exe | ./f.exe Composition of functions using 2 the Unix pipe symbol (same for 16 Windows and DOS too) 4 256 f o f(6) = f(f(6)) = f(36) 6 = 36 * 36 1296 = 1296 [jacobson@math-cs ~]$ [jacobson@math-cs ~]$ ./f.exe < A.dat <-- INPUT REDIRECTION - SEE HANDOUT. 1 4 9 16 25 36 49 64 81 100 [jacobson@math-cs ~]$ more A.dat THIS IS THE DOMAIN set A.dat is set A 1 A = {1,2,3,4,5,6,7,8,9,10} 2 3 4 5 6 7 8 9 10 See you on Friday, in the Wright 112 lab. Mark