lec3 environments binding and scope

lec3 environments binding and scope - ! " # $ % $ % $...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ! " # $ % $ % $ / (( 0 $ 3% # & & - '& + & (( 0 & # '( ) *+ , 0 + . 08 7 Expressions ' ., 8 09 09 < ' 0, . 1 2+ , 7 + 3-+ 4 4 5 .+ 0 ; /( 06 ( .+ + 0 ( .+ 7# )5 ( 8 -+ &9 ( & -+ ( : .+ 2 $ -+ ( 4 5 $ .+ 7 -+ 9 ( & 0 + + ; 0 + $ = $ ( $ > $ $ 3 + @ + .+ = (8 8 .+ if (1 < 2) then 5 else 10 * C7 29D70&9E + -* +. -. *. = < && || not ? ) . & if (1 < 2) then ["ab";"cd"] else ["x"] = (8 8 - .+ .+ ) B 2 0 0 & 2 .fieldname (; ) ( & (( -+ e1 if e1 then e2 else e3 : if e1 then e2 else e3 e1 e2 if e1 then e2 else e3 $ @ 2 )A ) &) ) & & 2 (; ) ( -+ e1 e2 if e1 then e2 else e3 1 = (8 8 .+ if (1 < 2) then [1;2] else 5 if false then [1;2] else 5 = (8 8 e1 .+ : if e1 then e2 else e3 $ 3 8 2 .+) 0 -+ 8 2 .+ ( .+ ; -+ B $ 3 @ : 8 2 .+) -+ ( 8 2 .+ .+ ; -+ B @ F# if 1>2 then [1;2] else CE e1 : if e1 then e2 else e3 if 1<2 then else ["a"] CE (if 1>2 then [1;2] else )=(if 1<2 then else ["a"]) " . < 2 < G # G # 2 ; 7 &> & 2 9 ; 5 H 2 H # let x = 2+2;; val x : int = 4 let x = e;; 7> & ; ; ( .+ 2 e x9 < 2 # let val x # let val y # let val z x : y : z : &> & = 2+2;; int = 4 = x * x * x;; int = 64 = [x,y,x+y];; int list = [4,64,68] ; G # 5 7 $< $< & # ; 2 2 69 2 J7 J 7+ 9 2 9 & 0 @ 5 0 & .+ 72 &9 ; 0 &( x ; & "/B 6 I ; H 2 ; 5 $ 2 & ; 7 +8 ; 9 2 & ; 7 $< $< ; 2 69 2 J7 J 7+ 9 2 9 let x = e;; 5 + ; 4 4 ' + ; . & # J : 0 (; 2 2 & 2 & ; & ; & 2- ; .+ e 0 ; 2 &x . 2 & , 4 ; & & 0 ; (; 2 4 . & %&& # 2 & & ( 7+ 2 69 . + 4 ; 4 . x ; 0 & %&& # 2 & 2 & &; (; # let x = 2+2;; val x : int = 4 # let y = x * x * x;; val y : int = 64 # let z = [x,y,x+y];; val z : int list = [4,64,68] G # & (( ( I x ; K 7 9H x y # let x = 2+2;; val x : int = 4 # let f = fun y -> x + y; val f : int -> int = fn # let x = x + x ; val x : int = 8 # f 0; val it : int = 4 x y z x f ( L ! "! # let x = x + x ;; val x : int = 8 x y z x " # 2 & $ " 0 $ / &2 & ( ! f ; 4 ; 4 . 0 & %&& # 2 & 2 & &; (; 4 ; 4 . ; 0 & %&& # 2 & 2 & &; (; G # & (( ( I x ; K 7 9H G # & (( ( I ; K 7 9H - val x = 2+2; val x = 4 : int - val f = fn y => x + y; val f = fn : int -> int - val x = x + x ; val x = 8 : int; - f 0; val it = 4 : int # let x = 2+2; val x : int = 4 # let f = fun y -> x + y;; val f : int -> int = fn ( L ! "! x f x f x > & # let x = x + x ; val x : int = 8 x f x ( L & ; ! (f ...) "! ( L ! "! # f 0; val it : int = 4 > & ( 2 : x 3 0 $ $ ; $ ! 1 ; 7 . 9 ; 2 & ; 2- && (( 0 + ; ( & & 0 ; & H # ( (; ( ! ++ 0 & 2 & 2 & ( 7; (f ...) 9 $ $ ; $ ! ; 7 . 0 2 & ; 2- && (( 0 + ; ( & & 0 ; & 2 + 0 # & 2 2 9 ; + # ; ( (; ( ! ++ 0 H + ( # & # - + & 0 ( ! & 2 & 2 & ( 7; (f ...) 9 9 # let x = 2+2;; val x : int = 4 # let f = fun y -> x + y;; val f : int -> int = fn # let x = x + x ;; val x : int = 8; # f 0;; val it : int = 4 > & x f x ( L & ; ! (f ...) "! 1 % 0 $ " $ ; (& 0 (( 0 ( 0 + > & ( 2 : x @ 0 ! @ 0 ! @ " 7 (( 0 . $ 3 + $ @ 3 + 2 0 ; ) " 2 F + && 2 ( ) & 7( 4 0 9 ( ; 0 0 ; 2 & )0 2 & val let fname = fun x -> e ;; 2 K & ( fname 2 & ( $ ' 7 &9, 2 & 0 0 ( ; ( 0 B + ; 00 0 ( fname (( 0 # &+ 2 && ( H - & e $ + $ M # + K 2 7 + 8 ! 0 & 9 + ( & 8 & 2 ) . (( 0 0 - let rec fname x = e ;; / 00 0 ( fname & e 2 & 7 9& ( 0 2 0 0 )0 ) & 2 - let rec fac x = if x<=1 then 1 else x*fac (x-1) 0 ( 2 & 2 & -9 ; 2 0 + & 2 8 .+ 8 ; ; 4 ' . -, & & ; Cx e2 E .+ e1 B ; ; 82 & ( '7 & ( 0 2 9, 0 ; 4 4 ; 2 & 8 . ; .+ e1 & & Cx ; E ; ; e2 0 )7 + $ %; & + $ 5 6 ( 0 let x = 10 in x * x ;; x #$ let x = e1 in e2 ;; ; 4 4 8 ; 4 4 8 ; . .+ ; .+ e1 & & Cx ; E ; ; B e2 " ; 4 4 ; &2 & 8 . ; .+ e1 & & Cx ; E ; ; e2 let y = let val x = 10 in x * x ;; y x #$ let x = 10 in (let y = 20 in x * y) + x ;; x #$ x y x #$ #$ $ #$$ " &2 & . + let x = 10 in let y = 20 in x * y ;; let x = 10 in let y = 20 in x * y ;; 0 let rec filter (f,l) = if l = then else let h = hd l in let t = filter (f, tl l) in if (f h) then h::t else t " &( 0 2 & $< # ; ( 0 ( ++ 0 ; & ( 0 + 2 0 &0 2 & ; 0 let a = 20;; let f let let a ;; f 0; x y g + = ; ( ! = 10 in $ & z = y + z in $ < (g x) ( ! ( ; 2 6 && & ++ 0 @ ; @ 5 @ -I+ & &) # $ @ @ ; 82 & ; = 2 I/ ( ! 2 ; 0 ( & ( ( 0 0 ; -0 5 0 + $ > &0 + . .+ ' 0I # 0 + , ; 2 .0 0 + 2 2 & 0 + ( # 2 ) . & ( & ; 0 2 & & in8 .+ $ : # @ 5 0 let-in .+ @ 3 let 2 & ; 2 @ # 2 & 00 + 0 ; 0 ; $ @ 1 0I .0 . 0 + &( - + . $ < @ @ K : ( ; ) ( ( 0 & 2 -6 -) & 2 9 ; ( 2 0 & 00 0 7# # & ( " . 0 Expressions < 3-+ 1 K ; ( ( 0 H 6 ...
View Full Document

This note was uploaded on 02/14/2008 for the course CSE 130 taught by Professor Jhala during the Fall '06 term at UCSD.

Ask a homework question - tutors are online