# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

3 Pages

### fp-scm

Course: COMS 541, Fall 2009
School: Iowa State
Rating:

Word Count: 549

#### Document Preview

541 CS Lecture -*- Outline -*- * FP systems (may omit) John Backus's langauge, from his turing award lecture in contrast to systems based on lambda calculus, no way to make new combining forms (i.e. can only name compositions of built-in things) ** FP primitives ***all functions are unary if need more than one argument, take list of args ------- (define (apply2 f p) (cond ((equal? (length p) 2) (f (car p)...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Iowa >> Iowa State >> COMS 541

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
541 CS Lecture -*- Outline -*- * FP systems (may omit) John Backus's langauge, from his turing award lecture in contrast to systems based on lambda calculus, no way to make new combining forms (i.e. can only name compositions of built-in things) ** FP primitives ***all functions are unary if need more than one argument, take list of args ------- (define (apply2 f p) (cond ((equal? (length p) 2) (f (car p) (cadr p))) (else (error "wrong number of arguments to" f)))) (define (fp-ize f) (lambda (p) (apply2 f p))) (define fp-plus (fp-ize +)) (define fp-times (fp-ize *)) ; etc. ------ ***reduction functional, red --------- (define (red f) (define (fp-reduce f lst) ; requires: lst is non-empty (cond ((null? (cdr lst)) (car lst)) (else (f (list (car lst) (fp-reduce f (cdr lst))))))) (lambda (lst) (fp-reduce f lst))) --------- ((red fp-plus) '(1 2 3 4)) ; Value: 10 ***mapping functional ------- (define (fp-map f) (lambda (l) (map f l))) ------- ((fp-map fp-plus) '((5 6) (7 8))) ; Value: (11 15) ***composition functional -------- (define compose (fp-ize (lambda (f g) (lambda (x) (f (g x)))))) -------- ((compose (list fp-times fp-map fp-plus)) '((5 6) (7 8))) ;Value: 165 ((compose `(,fp-times ,fp-map ,fp-plus)) '((5 6) (7 8))) ;Value: 165 ***constant functional --------- (define (const k) (lambda (x) k)) --------- ((const 3) 4) ;Value: 3 ***transposition --------- (define (transpose ll) (define (map2 f l1 l2) (cond ((or (null? l1) (null? l2)) '()) (else (cons (f (car l1) (car l2)) (map2 f (cdr l1) (cdr l2)))))) (map2 list (car ll) (cadr ll))) --------- (transpose '((1 2 3) (4 5 6))) ;Value: ((1 4) (2 5) (3 6)) ***distribute left and right --------- (define (distl xl) (let ((x (car xl)) (l (cadr xl))) (map (lambda (y) (list x y)) l))) (define (distr lx) (let ((x (cadr lx)) (l (car lx))) (map (lambda (y) (list y x)) l))) --------- (distl '(5 (1 2 3))) ; Value: 1) ((5 (5 2) (5 3)) (distr '((1 2 3) 5)) ; Value: ((1 5) (2 5) (3 5)) *** constructor functional -------- ; turns list of functions into a function (define (constr lf) (define (fun-list-apply lf x) (cond ((null? lf) '()) (else (cons ((car lf) x) (fun-list-apply (cdr lf) x))))) (lambda (x) (fun-list-apply lf x))) -------- ((constr `(,fp-plus ,fp-times ,fp-plus)) '(3 4)) ; Value: (7 12 7) ** Example: vector product ---------- (define fp-vec-prod (compose `(,(fp-map fp-times) ,transpose))) ---------- (fp-vec-sum '((1 2 3) (4 5 6))) ; Value: (4 10 18) ** Example: inner product (ip U V) = sum of U[i]*V[i] ---------- (define ip (compose (list (red fp-plus) fp-vec-prod))) ---------- (ip '((1 2 3) (4 5 6))) ; Value: 32 ** Example: matrix multiplication ---------- (define prod-row (compose `(,(fp-map ip) ,distl))) (define mat-prod (compose (list (compose (list (fp-map prod-row) distr)) (constr (list car (compose (list transpose cadr))))))) ; (mat-prod '(((1 2 3) (4 5 6)) ; ((7 8) (9 10) (11 12) (13 14)))) ;Value: ((25 28) (73 82)) ---------- derivation of matrix multiplication point: simple, but unfamiliar, equational reasoning let A be l*m, B be m*n matricies want: (mat-prod A B) = (P[i,k]) where P[i,k] = sum from j=1 to m of A[i,j]*B[j,k]. so P[i,k] = (ip (list A[i,*] B[*,k])) notation: P[i,*] = (list P[i,1] ... P[i,n]) so P[i,*] = ((fp-map ip) (list (list A[i,*] B[*,1]) ... (list A[i,*] B[*,n]))) factor out the constant argument with distl so P[i,*]= ((compose (list (fp-map ip) distl)) (list A[i,*] (transpose B))) (define prod-row (compose (list (fp-map ip) distl))) do this for each row of A so P = ((fp-map prod-row) (list (list A[1,*] (transpose B))... (list A[l,*] (transpose B)))) factor out the (transpose B) using distr P = ((compose (list (fp-map prod-row) distr)) (list A (transpose B))) given (list A B) get back (list A (transpose B)) using (constr (list car (compose (list transpose cadr))))
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Iowa State - COMS - 541
CS 541 Lecture -*- Outline -*-* FP systems (may omit)John Backus's langauge, from his turing award lecturein contrast to systems based on lambda calculus,no way to make new combining forms(i.e. can only name compositions of built-in thin
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 1: INDUCTION and RECURSION (File \$Date: 96/09/14 18:19:41 \$)Due: problems 1-2, 5-6, at beginning of class, September 20; problems 7 at beginning of class, September 23;
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* procedures (1.3)* as dataare values in Scheme-PROCEDURES (1.3)Values + abstract: partial mappings from a domain to a rangewith side-effects on store + syntax of printed output: ?in SCM: #&lt;CL
Iowa State - COMS - 541
imokay :- youreokay, hesokay. %C1youreokay :- theyreokay. %C2hesokay. %C3theyreokay. %C4?- imokay.hesnotokay :- imnotokay. %C5shesokay :- hesnotokay. %C6shesokay :- theyreokay. %C7?- shesokay.hesnotokay :- shesokay. %C8hesnotok
Iowa State - COMS - 541
CS 541 Lecture -*- Outline -*-* Resolution (logical basis for Prolog)* An abstract interpreterkeeps a set of goals, called a resolvent-input: a logic program P, and a goal Goutput: a substitution s, if s[G] is deducible from P,or failure
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* Interpreter for Schemeadvert: more elegant than others so far, fewer special cases compare with LISP (only a few lines longer, more power)* environmentsmost important changeenvironment frame (stack frame
Iowa State - COMS - 342
Com S 342 - Principles of Programming LanguagesHOMEWORK 4: REDUCTION RULES AND IMPERATIVE PROGRAMMING (File \$Date: 1997/10/15 21:24:23 \$)Due: problems 1-3,8-10,12-13 at beginning of class, October 13. problems 20,21,23,28-32 at be
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 6: PARAMETER PASSING (File \$Date: 1997/11/12 16:16:00 \$)Due: problems 2-5,8-10,13,15-16,17-18,20-21 at beginning of class, November 17.In this homework, you will learn abou
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* the SASL interpreter* thunks = expression + environmentnote: different case from closurein a closure expression has to be lambda (parameters + body)* printing thunksprValue doesn't get their value.* eval
Iowa State - COMS - 342
* the SASL interpreter* thunks = expression + environment* printing thunks* evaluation* real SASL* if syntax* pattern matching (as in ML)* ZF expressions* lambda calculus* key idea: using thunks to represent data and control* booleans and
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* reachability problem for positive 2-dimensional vector systemsadvert: slick use of lazy evaluation for modularitydistinction between breadth-first and depth first searchthat is similar to what will be import
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 2: FORMULATING ABSTRACTIONS WITH HIGHER-ORDER PROCEDURES (File \$Date: 1999/09/14 22:02:09 \$)Due: problems 1-3, September 16, 1999; 4-6, September 30, 1999.(Note: on September 30 you
Iowa State - COMS - 342
CS 342 Lecture -*-Outline-*-* the CLU interpreter (6.3)point is to see how the settors, selectors and constructor workalso 2 part names* ClustersHow are clusters represented?CLUSTERREC on page 222note field names i nclrepexported
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* syntax abstraction (EOPL 3)a key idea in language design- THE IDEA OF SYNTAX ABSTRACTIONproblem: users doing same thing over and overmaking local bindingsdeeply nesting if expressions. but
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 6: PARAMETER PASSING (File \$Date: 96/12/01 19:26:50 \$)Due: problems 2-5, 8-10,13,15,16 at the beginning of class, April 29. problems 17,18,20-21 at the beginning of clas
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 1: INDUCTION and RECURSION (File \$Date: 96/02/15 13:19:41 \$)Due: problems 1-2, 5-6, in your discussion section, February 6; problems 8, 11,14-16 in your discussion section,
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* A Simple Interpreter (5.1)* overview- WHAT AN INTERPRETER DOES (5.1) concrete syntax | v abstract -&gt; Expressed syntax Value-
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 5: INTERPRETERS (File \$Date: 1998/11/04 16:50:33 \$)Due: problems 4-6 at beginning of class, November 2; problems 8,12-14,16 at beginning of class, November 6, pr
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* Adding Arrays (6.1) Note: Remind students to get the revised chapter 6, if they have an older copy of the book! Warning to students: we do things differently, even
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* Call-by-Name and Call-by-Need (6.5)* call-by-name* informal overview (using the indirect array model)Call-by-name was first used in Algol 60* motivationQ: Does any parameter mechanism correspond to bet
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* Call by Value-Result and call-by-result (6.3)* informal overview* motivation- MOTIVATION FORCALL BY VALUE-RESULTHow would a compiler access a formalusing:- call by value?- call by reference?
Iowa State - COMS - 541
Com S 541 Lecture -*- Outline -*-* Closures and Functions (Thompson 9 and 10, Davie 5)&gt; module Functionals where&gt; import Prelude hiding (sum, product, curry, foldr)&gt; import List hiding (sum, product, foldr)* \ makes functions this is
Iowa State - COMS - 541
Com S 541 Lecture -*- Outline -*-&gt; module ListLecture where&gt; import Prelude hiding (fst, snd, head, tail, filter, zip)* lists (Thompson 4, Davie 2.8, 3.11)- LISTS IN HASKELL[a] - homogeneous lists of a Values: + abstract values
Iowa State - COMS - 342
Com S 342 lecture -*- Outline -*-* Course evaluation guidelines* ideathese are used to evaluate the course and our teaching.Department takes these seriously, e.g. for salary.Need volunteer for taking them back to departmentoffice (226 At
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* course project* predicates from Springer &amp; Friedmansee Scheme and Art of Programming, chapter 8* 4-part voice leadinginput: initial chord and base linechord = list of 4 notes (in order: s a t b)such t
Iowa State - COMS - 541
CS 541 Lecture -*- Outline -*-* higher order features of lambda prolog reference: An Overview of Lambda Prolog by Nadathur and Miller (5th Intl. Conf. on Logic Prog., MIT Press, 1988) and Dale Miller
Iowa State - COMS - 541
Com S 541 lecture -*- Outline -*-* Course evaluation guidelines* ideathese are used to evaluate the course and our teaching.Department takes these seriously, e.g. for salary.Need volunteer for taking them back to departmentoffice (226 At
Iowa State - COMS - 541
CS 541 Meeting -*- Outline -*-* Types and Classes in OOP and Javaidea: (static) analysis to verify certain program propertiesand prevent run-time type errors* Basic concepts* type and type error- BASIC CONCEPTS OF TYPE AND CLASSRec
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* exam preparation for problem solving* language vs. data structures available*LISP:lists, sets, relations, queues*Scheme: lists, sets, functions*CLU: lists, points, polynomials, arrays, your own*Smalltalk:
Iowa State - COMS - 342
CS 342 Lecture -*- Outline -*-* Programming lessonsLISP: how to write recursive functionsbase, inductive casemake program structure match structure of dataCLU: the utility of data abstractioninformation hiding (keep rep details in t
Iowa State - COMS - 342
Com S 342 meeting -*- Outline -*-* Objectives overview* what it's notThe objective is not to teach you specific languages that youcan put on your resume (useful skills)* what it isinstead the main objective is to exploreprogramming lang
Iowa State - COMS - 541
Com S 541 Lecture -*- Outline -*-* Overview of Scala based on: Odersky et al.'s An Overview of the Scala Programming Language (EPFL Tech Rep. IC/2004/64) Odersky et al.'s The Scala Language Specification (versio
Iowa State - COMS - 342
Com S 342 - Principles of Programming Languages HOMEWORK 5: INTERPRETERS (File \$Date: 1995/11/16 22:14:24 \$)Due: problems 1-2,4-5,9-10 at beginning of your discussion section, October 27; problems 0,13 at the beginning of c
Iowa State - COMS - 541
CS 541 Lecture -*- Outline -*-* why study the theory of programming languages?* arguments for the study of theory* need to abstract and generalizealready seen the major kinds of languages,learning new languages would be mostly details.w
Iowa State - COMS - 541
I. Introduction to Haskell A. interaction (Thompson chapter 2, replaces Davie 2.1)- INTERACTING WITH THE INTERPRETER\$ hugs _ _ _ _ _ _ | | | | | | |_ |_| |_| |_| __| |-| _| | |
Allan Hancock College - COMP - 2303
Starting:gdbgdb &lt;file&gt;gdb -h (lists command line options)Exiting:quitCtrl-dNote: Ctrl-C does not exit from gdb, but halts the currentgdb commandGeneral commandsrun(start your program)kill(stop the program)Breakpoints
Iowa State - CS - 611
%!PS-Adobe-2.0 %Creator: dvips 5.76 Copyright 1997 Radical Eye Software (www.radicaleye.com) %Title: errata.dvi %CreationDate: Thu Jul 3 16:06:27 2003 %Pages: 5 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips -o bgi
Iowa State - CS - 611
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: mobile.dvi %Pages: 10 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips mobile -omobile.ps %DVIPSP
Iowa State - CS - 611
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: paper.dvi %Pages: 18 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Helvetica-Bold Times-Italic Times-Roman Helvetica %EndComments %DVIPSCommandLine
Iowa State - CS - 611
%!PS-Adobe-2.0 %Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %Title: layers-tr.dvi %Pages: 43 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Italic Times-Bold Courier %+ Times-BoldItalic Helvetica %Docume
Iowa State - CS - 611
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: disc.dvi %Pages: 15 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMBX12 CMBXTI10 CMR10 CMR7 CMMI7 CMR6 CMR9 CMSY9 CMTT9 %+ CMBX9 CMTI9 CMTI10 CMMI10 C
Virginia Tech - PHYS - 2306
35.8: a)For the number of antinodes we have: m mc m(3.00 108 m s) sin = = = = 0.2317 m, so, setting = 90, d df (12.0 m)(1.079 108 Hz) the maximum integer value is four. The angles are 13.4, 27.6, 44.0, and 67.9 for m = 0, 1, 2, 3, 4. (m +
George Mason - ISA - 774
GMU ISA 774 Intrusion Detection Spring `06 Homework 1 Due date March 7, 2006, via email to me and the TA. Subject line of email should start &quot;ISA 774 HW1&quot; 1. Briefly describe the differences between anomaly detection and misuse detection 2. Briefly
Virginia Tech - PHYS - 2306
35.12: The width of a bright fringe can be defined to be the distance between its two adjacent destructive minima. Assuming the small angle formula for destructive interference (m + 1 ) 2 ym = R , d the distance between any two successive minima is
Virginia Tech - PHYS - 2306
35.16: (a)Dark fringe implies destructive interference. 1 d sin = 2 624 10 9 m d= = = 1.64 10 6 m 2 sin 2 sin 11.0 (b)Bright fringes: d sin max = mmax 1.6410 m The largest that can be is 90, so mmax = d / = 624109 m = 2.6 Since m is an int
Virginia Tech - PHYS - 2306
35.23:a)The distance from the central maximum to the first minimum is half the distance to the first maximum, so: R (0.700 m) (6.60 10 7 m) y= = = 8.88 10 4 m. 4 2d 2(2.60 10 m) b)The intensity is half that of the maximum intensity when you are ha
Virginia Tech - PHYS - 2306
35.24:a) =c 3.00 108 m/s = = 2.50 m, and we have: f 1.20 108 Hz 2 2 (r1 r2 ) = (1.8 m) = 4.52 rad. = 2.50 m 2 2 4.52 rad = 0.404 I 0 . b) I = I 0 cos = I 0 cos 2 2
Virginia Tech - PHYS - 2306
35.40:Destructive interference occurs 1.7 m from the centerline. r1 = (12.0 m) 2 + (6.2 m) 2 =13.51 m r2 = (12.0 m) 2 + ( 2.8 m) 2 =12.32 m For destructive interference, r1 r2 = / 2 = 1.19 m and = 2.4 m. The wavelength we have calculated is the
Virginia Tech - PHYS - 2306
35.53: a)There is a half-cycle phase change at the glass, so for constructive interference: 1 x 2d x = 2 h + x = m + 2 2 2 21 x 2 + 4h 2 x = m + . 2 Similarly for destructive interference: x 2 + 4h 2 x = m.b)The longest wavelengt
Virginia Tech - PHYS - 2306
21.2:current 20 ,000 C s and t 100 s 10 Q = It = 2.00 C Q ne 1.25 10 19. 19 1.60 10 C4s
Virginia Tech - PHYS - 2306
21.36: a) x b) vv01 2 at 2at2(0.0160 m) (1.67 10 27 kg) 1 eE 2 t E 2 mp (1.60 10 19 C) (1.50 10 6 s) 2 eE t 2.13 10 4 m s . mp148 N C .
Virginia Tech - PHYS - 2306
21.37: a) tan c) tan111.35 0 , r 2^ jb) tan112 .2 ^ ,r 42^ i 22^ j 22.6 1.10^ 1.97 radians 112.9 , r^ 0.39i0.92 ^ (Second quadrant). j