# Values computed from values of sub ex 50 70 40 30 20

• Notes
• ProfessorResolvePartridge10091
• 4

This preview shows pages 2–4. Sign up to view the full content.

Values computed from values of sub-expressions 2.0 +.3.0 5.0 7.0 –. 4.0 3.0 (2.0 +. 3.0) /. (7.0 -. 4.0) 1.66.. 2.0 2.0 r:float r r e e 1 : float e 1 : float e 1 +.e 2 : float e1 v1 e2 v2 e1+.e2 v1+.v2 e1 +. e2 e1 -. e2 e1 /. e2 e 1 : float e 2 : float e 1 -.e 2 : float e1 v1 e2 v2 e1-.e2 v1-.v2 e 1 : float e 2 : float e 1 /.e 2 : float e1 v1 e2 v2 e1/.e2 v1/.v2 Base Type: string Expressions built from sub-expressions Types computed from types of sub-expressions Values computed from values of sub-expressions “ab” ^ “cd” “abcd” “ab” “ab” s : string s s s e 1 : string e 2 : string e 1 ^e 2 : string e1 v1 e2 v2 e1^e2 v1^v2 e1^e2 Base Type: bool 2 < 3 true not(2<3) false (“ab”=“cd”) false true true b : bool b b b e 1 : int e 1 : int e 1 < e 2 : bool e1 v1 e2 v2 e1<e2 v1<v2 e1 < e2 not e e1 = e2 e : bool not e : bool e v not e not v e 1 : T e 2 : T e 1 =e 2 : bool e1 v1 e2 v2 e1=e2 v1=v2 not (2<3) && (“ab”=“cd”) false e1 && e2 e 1 : bool e 2 : bool e 1 &&e 2 : bool e1 v1 e2 v2 e1&&e2 v1 && v2 Base Type: bool (“ab”=“cd”) false e1 = e2 e 1 : T e 2 : T e 1 =e 2 : bool e1 v1 e2 v2 e1=e2 v1=v2 Equality testing is built-in for all expr,values,types but compared expressions must have same type …except for ? function values … why ? Type Errors (2 + “a”); “pq” ^ 9; e 1 : string e 2 : string e 1 ^e 2 : string e 1 : int e 2 : int e 1 + e 2 : int Expressions built from sub-expressions Types computed from types of sub-expression If a sub-expression is not well-typed then whole expression is not well-typed 0 * (2 + “a”);

This preview has intentionally blurred sections. Sign up to view the full version.

3 Complex types: Tuples e1 : T1 e2 : T2 ( e 1 ,e 2 ) : T1 * T2 (2+2 , 7>8); (4,false) int * bool e1 v1 e2 v2 (e1,e2) (v1,v2) Complex types: Tuples e1 : T1 e2 : T2 en: Tn ( e1,e2,…,en ) : T1 * T2* …* Tn e1 v1 e2
This is the end of the preview. Sign up to access the rest of the document.
• Spring '10
• CS
• Sort, Expression, Type system

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern