Functor (1A) Young Won Lim 10/5/17

Size: px
Start display at page:

Download "Functor (1A) Young Won Lim 10/5/17"

Transcription

1

2 Copyright (c) Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published by the Free Softwre Foundtion; with no Invrint Sections, no Front-Cover Texts, nd no Bck-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documenttion License". Plese send corrections (or suggestions) to youngwlim@hotmil.com. This document ws produced by using OpenOffice.

3 Bsed on Hskell in 5 steps 3

4 Function Definition Function Definition I. squre x = x * x - function type is inferred not efficient Type Inference Function Definition II. squre :: Double -> Double function type declrtion squre x = x * x Function Type Declrtion function type declrtion function definition Type Declrtion the declrtion of n identifier's type the identifier nme :: the type nme... type nmes in Hskell lwys begin with cpitl letter, identifier nmes (including function identifiers) must lwys begin with lower-cse letter 4

5 Function Types nd Type Clsses Function Definition I. squre x = x * x function definition = Function Definition II. squre :: Double -> Double squre x = x * x function definition function type declrtion = type clss set of types function type 1 function type 2 function type n 5

6 Typeclsses nd Instnces Typeclsses re like interfces defines some behvior compring for equlity compring for ordering enumertion such behvior is defined by function type declrtion only function definition Instnces of tht typeclss types possessing such behvior function definition (==) :: -> -> Bool - type declrtion x == y = not (x /= y) function type (==) :: -> -> Bool - type declrtion A function definition cn be overloded 6

7 Typeclsses nd Type Typeclsses re like interfces defines some behvior compring for equlity compring for ordering enumertion type is n instnce of typeclss implies the function types declred by the typeclss re defined (implemented) in the instnce so tht we cn use the functions tht the typeclss defines with tht type Instnces of tht typeclss types possessing such behvior No reltion with clsses in Jv or C++ 7

8 Cr Type Exmple the Eq typeclss defines the functions == nd /= type Cr compring two crs c1 nd c2 with the equlity function == The Cr type is n instnce of Eq typeclss Instnces : vrious types Typeclss : group or clss of these similr types type Cr type Bg type Phone instnces Eq typeclss functions == nd /= 8

9 TrfficLight Type Exmple (1) clss Eq where (==) :: -> -> Bool - type declrtion (/=) :: -> -> Bool - type declrtion x == y = not (x /= y) - function definition x /= y = not (x == y) - function definition dt TrfficLight = Red Yellow Green instnce Eq TrfficLight where Red == Red = True Green == Green = True Yellow == Yellow = True _ == _ = Flse ghci> Red == Red True ghci> Red == Yellow Flse ghci> Red `elem` [Red, Yellow, Green] True 9

10 TrfficLight Type Exmple (2) clss Show where show :: -> String * * * - type declrtion dt TrfficLight = Red Yellow Green instnce Show TrfficLight where show Red = "Red light" show Yellow = "Yellow light" show Green = "Green light" Instnce type TrfficLight Eq typeclss Show typeclss ghci> [Red, Yellow, Green] [Red light,yellow light,green light] 10

11 Clss Constrints clss (Eq ) => Num where... (Eq ) => Eq typeclss clss Num where... instnce clss constrint on clss declrtion Num typeclss n instnce of Eq before being n instnce of Num Num : subclss of Eq the required function bodies cn be defined in the clss declrtion n instnce declrtions, we cn sfely use == becuse is prt of Eq 11

12 Clss Constrints : clss & instnce declrtions clss constrints in clss declrtions to mke typeclss subclss of nother typeclss subclss clss (Eq ) => Num where clss constrints in instnce declrtions to express requirements bout the contents of some type. requirements instnce (Eq x, Eq y) => Eq (Pir x y) where Pir x0 y0 == Pir x1 y1 = x0 == x1 && y0 == y

13 Clss constrints in instnce declrtion exmples instnce (Eq m) => Eq (Mybe m) where Just x == Just y = x == y Nothing == Nothing = True _ == _ = Flse Eq m instnce (Eq x, Eq y) => Eq (Pir x y) where Pir x0 y0 == Pir x1 y1 = x0 == x1 && y0 == y1 Eq (Pir x y) Eq x Eq y Derived instnce 13

14 A Concrete Type nd Type Constructor : concrete type Mybe : not concrete type : type constructor tht tkes one prmeter produces concrete type. Mybe : concrete type 14

15 Functor typeclss the Functor typeclss is bsiclly for things tht cn be mpped over ex) mpping over lists the list type is prt of the Functor typeclss 15

16 Functor typeclss clss Functor f where fmp :: ( -> b) -> f -> f b func b The Functor typeclss defines one function, fmp no defult implementtion the type vrible f not concrete type ( concrete type cn hold vlue) type constructor tking one type prmeter f fmp function fmp function func type constructor f f b Mybe Int : concrete type Mybe : type constructor tht tkes one type s the prmeter 16

17 Function mp & fmp clss Functor f where fmp :: ( -> b) -> f -> f b fmp tkes function from one type to nother ( -> b) Functor f pplied with one type (f ) fmp returns Functor f pplied with nother type (f b) function type type ( -> b) -> f -> f b func mp :: ( -> b) -> [] -> [b] mp tkes function from one type to nother (* 2) tke list of one type [ 1, 2, 3 ] returns list of nother type [ 2, 4, 6 ] 17

18 List : n instnce of the Functor typeclss clss Functor f where fmp :: ( -> b) -> f -> f b func b mp :: ( -> b) -> [] -> [b] f fmp f b mp is just fmp tht works only on lists list is n instnce of the Functor typeclss. function fmp function func type constructor f instnce Functor [ ] where fmp = mp func b f : type constructor tht tkes one type [ ] : type constructor tht tkes one type [] : concrete type ([Int], [String] or [[String]] ) mp [ ] [ b ] 18

19 List Exmples clss Functor f where fmp :: ( -> b) -> f -> f b mp :: ( -> b) -> [] -> [b] instnce Functor [ ] where fmp = mp mp :: ( -> b) -> [] -> [b] ghci> fmp (*2) [1..3] [2,4,6] ghci> mp (*2) [1..3] [2,4,6] *2 1 2 mp [1,2,3] [2,4,6] 19

20 Mybe : n instnce of the Functor typeclss clss Functor f where fmp :: ( -> b) -> f -> f b func b instnce Functor Mybe where fmp func (Just x) = Just (func x) f fmp f b fmp func Nothing = Nothing f Mybe func b f Mybe f b Mybe b Mybe fmp Mybe b ( -> b) func 20

21 Mybe : type constructor clss Functor f where fmp :: ( -> b) -> f -> f b func b instnce Functor Mybe where fmp func (Just x) = Just (func x) f fmp f b fmp func Nothing = Nothing f : type vrible func b f : type constructor tking one type prmeter Mybe : n instnce of Functor typeclss Mybe fmp Mybe b 21

22 Mybe : n rgument to fmp, together with clss Functor f where fmp :: ( -> b) -> f -> f b func b instnce Functor Mybe where fmp func (Just x) = Just (func x) f fmp f b fmp func Nothing = Nothing func b fmp :: ( -> b) -> f -> f b Mybe fmp Mybe b fmp func (Just x) = Just (func x) Just x Just (func x) fmp func Nothing = Nothing Nothing Nothing 22

23 A function rgument to fmp nd Functor f clss Functor f where fmp :: ( -> b) -> f -> f b f f b instnce Functor Mybe where fmp func (Just x) = Just (func x) func f fmp f b fmp func Nothing = Nothing instnce Functor Mybe where func b fmp f (Just x) = Just ( f x) f fmp f Nothing = Nothing f b f is different from the type constructor f func : -> b Mybe fmp Mybe b f : -> b 23

24 Mybe Exmples (1) clss Functor f where fmp :: ( -> b) -> f -> f b f func b instnce Functor Mybe where fmp f (Just x) = Just (f x) f f fmp f b fmp f Nothing = Nothing ghci> fmp (*2) (Just 200) Just 400 ghci> fmp (*2) Nothing Nothing * fmp Just 200 Just

25 Mybe Exmples (2) clss Functor f where fmp :: ( -> b) -> f -> f b f func b instnce Functor Mybe where fmp f (Just x) = Just (f x) f f fmp f b fmp f Nothing = Nothing ghci> fmp (++ "BBB") (Just "AAA") "AAA" (++ "BBB") "AAABBB" Just "AAABBB" ghci> fmp (++ "BBB") Nothing Nothing Just "AAA" fmp Just "AAABBB" 25

26 Mybe s functor Functor typeclss: trnsforming one type to nother trnsforming opertions of one type to those of nother Mybe is n instnce of functor type clss Functor provides fmp method mps functions of the bse type (such s Integer) to functions of the lifted type (such s Mybe Integer). 26

27 Mybe s functor A function f trnsformed with fmp cn work on Mybe vlue cse mybevl of Nothing -> Nothing Just vl -> Just (f vl) -- there is nothing, so just return Nothing -- there is vlue, so pply the function to it fther :: Person -> Mybe Person mother :: Person -> Mybe Person f :: Int -> Int fmp f :: Mybe Integer -> Mybe Integer Mybe Integer vlue: m_x fmp f m_x 27

28 Trnsforming opertions Functor provides fmp method mps functions of the bse type (such s Integer) to functions of the lifted type (such s Mybe Integer). f b Int f Int F fmp F b Mybe Int fmp f Mybe Int F Int fmp f F Int 28

29 Mybe s functor m_x : Mybe Integer vlue ( Just 101, Nothing, ) f :: Int -> Int you cn do fmp f m_x to pply the function f directly to the Mybe Integer without worrying whether it is Nothing or not clss Functor f where fmp :: ( -> b) -> f -> f b instnce Functor Mybe where fmp f (Just x) = Just (f x) fmp f Nothing = Nothing Function of ( -> b) fmp f m_x lifted type A Functor f pplied with one type f or f b 29

30 Mybe s functor Cn pply whole chin of lifted Integer -> Integer functions to Mybe Integer vlues nd only hve to worry bout explicitly checking for Nothing once when you're finished. Int f Int F Int g F Int Mybe Int fmp f Mybe Int Mybe F Int fmp g Mybe F Int F Int h Int Mybe F Int fmp h Mybe Int 30

31 Mybe Type Definition The Mybe type definition dt Mybe = Just Nothing deriving (Eq, Ord) clss Functor f where fmp :: ( -> b) -> f -> f b Mybe is n instnce of Eq nd Ord (s bse type) n instnce of Functor n instnce of Mond instnce Functor Mybe where fmp f (Just x) = Just (f x) fmp f Nothing = Nothing For Functor, the fmp function f moves inside the Just constructor nd is identity on the Nothing constructor. For Mond, the bind opertion psses through Just, while Nothing will force the result to lwys be Nothing. 31

32 Mybe clss The Mybe type definition dt Mybe = Just Nothing deriving (Eq, Ord) Mybe is n instnce of Eq nd Ord (s bse type) n instnce of Functor n instnce of Mond For Functor, the fmp function f moves inside the Just constructor nd is identity on the Nothing constructor. For Mond, the bind opertion psses through Just, while Nothing will force the result to lwys be Nothing. 32

33 Mond Mond is just specil Functor with extr fetures Monds like IO mp types to new types tht represent "computtions tht result in vlues" cn lift regulr functions into Mond types vi liftm function (like fmp function) liftm trnsform regulr function into "computtions tht results in the vlue obtined by evluting the function." 33

34 Mybe s Mond Mybe is lso Mond represents computtions tht could fil to return vlue" n immedite bort vlueless return in the middle of computtion. enble whole bunch of computtions without explicit checking for errors in ech step computtion on Mybe vlues stops s soon s Nothing is encountered 34

35 Mybe s Mond f::int -> Mybe Int f 0 = Nothing f x = Just x g :: Int -> Mybe Int g 100 = Nothing g x = Just x h ::Int -> Mybe Int h x = cse f x of Just n -> g n Nothing -> Nothing h' :: Int -> Mybe Int h' x = do n <- f x g n if x==0 then Nothing else Just x if x==100 then Nothing else Just x if f x==nothing then Nothing else g n g ( f x) h & h' give the sme results h 0 = h' 0 = h 100 = h' 100 = Nothing; h x = h' x = Just x 35

36 Mybe s Librry Function When the module is imported import Dt.Mybe mybe :: b->(->b) -> Mybe -> b Applies the second rgument (->b) to the third Mybe, when it is Just x, otherwise returns the first rgument (b). isjust, isnothing Test the rgument, returing Bool bsed on the constructor. ListToMybe, mybetolist Convert to/from one element or empty list. mpmybe A different wy to filter list. 36

37 Mybe s Mond mybe :: b->(->b) -> Mybe -> b The mybe function tkes defult vlue (b), function (->b), nd Mybe vlue (Mybe ). If the Mybe vlue is Nothing, the function returns the defult vlue. Otherwise, it pplies the function to the vlue inside the Just nd returns the result. >>> mybe Flse odd (Just 3) True >>> mybe Flse odd Nothing Flse Mybe.html 37

38 Then Opertor (>>) nd do Sttements putstr "Hello" >> putstr " " >> putstr "world!" >> putstr "\n" do { putstr "Hello" ; putstr " " ; putstr "world!" ; putstr "\n" } 38

39 Trnslting in do nottion do { ction1 ; ction2 ; ction3 } ction1 >> do { ction2 ; ction3 } ction1 ction2 ction3 do { ction1 ; do { ction2 ; ction3 } } do { ction1 ; do { ction2 ; do { ction3 } } } cn chin ny ctions s long s ll of them re in the sme mond 39

40 Bind Opertor (>==) nd do sttements The bind opertor (>>=) psses vlue (the result of n ction or function), downstrem in the binding sequence. ction1 >>= (\ x1 -> ction2 >>= (\ x2 -> mk_ction3 x1 x2 )) nonymous function (lmbd expression) is used do nottion ssigns vrible nme to the pssed vlue using the <- do { x1 <- ction1 ; x2 <- ction2 ; mk_ction3 x1 x2 } 40

41 Trnsltion using the bind opertor (>>=) do { x1 <- ction1 ; x2 <- ction2 ; mk_ction3 x1 x2 } ction1 >>= (\ x1 -> ction2 >>= (\ x2 -> mk_ction3 x1 x2 )) ction1 >>= (\ x1 -> ction2 >>= (\ x2 -> mk_ction3 x1 x2 )) ction1 >>= (\ x1 -> ction2 >>= (\ x2 -> mk_ction3 x1 x2 )) ction1 x1 ction2 x2 mk_ction3 41

42 Anonymous Function \x -> x + 1 (\x -> x + 1) 4 5 :: Integer (\x y -> x + y) :: Integer ddone = \x -> x + 1 Lmbd Expression 42

43 Functor Typeclss instnce Functor IO where fmp f ction = do result <- ction f b return (f result) IO fmp IO b ction1 result f f ction ( -> b) -> IO -> IO b instnce Functor Mybe where fmp func (Just x) = Just (func x) fmp func Nothing = Nothing f result 43

44 Functor Typeclss min = do line <- getline let line' = reverse line putstrln $ "You sid " ++ line' ++ " bckwrds!" putstrln $ "Yes, you relly sid" ++ line' ++ " bckwrds!" min = do line <- fmp reverse getline putstrln $ "You sid " ++ line ++ " bckwrds!" putstrln $ "Yes, you relly sid" ++ line ++ " bckwrds!" instnce Functor IO where fmp f ction = do result <- ction return (f result) fmp reverse getline = do result <- getline return (reverse result) 44

45 $ Opertor $ opertor to void prentheses Anything ppering fter $ will tke precedence over nything tht comes before. putstrln (show (1 + 1)) putstrln (show $ 1 + 1) putstrln $ show (1 + 1) putstrln $ show $

46 . Opertor. opertor to chin functions putstrln (show (1 + 1)) (1 + 1) is not function, so the. opertor cnnot be pplied show cn tke n Int nd return String. putstrln cn tke String nd return n IO(). (putstrln. show) (1 + 1) Int String IO() show putstrln putstrln. show $

47 Functor Typeclss instnce Functor ((->) r) where fmp f g = (\x -> f (g x)) instnce Functor Mybe where fmp f (Just x) = Just (f x) fmp f Nothing = Nothing A function tkes ny thing nd returns ny thing g :: -> b g :: r -> r g g b r g b fmp :: ( -> b) -> f -> f b fmp :: ( -> b) -> ((->) r ) -> ((->) r b) fmp :: ( -> b) -> (r -> ) -> (r -> b) f b g fmp g b 47

48 Functor Typeclss instnce Functor ((->) r) where fmp f g = (\x -> f (g x)) instnce Functor ((->) r) where fmp = (. ) instnce Functor Mybe where fmp f (Just x) = Just (f x) fmp f Nothing = Nothing ghci> :t fmp (*3) (+100) fmp (*3) (+100) :: (Num ) => -> ghci> fmp (*3) (+100) ghci> (*3) `fmp` (+100) $ ghci> (*3). (+100) $ ghci> fmp (show. (*3)) (*100) 1 "300" (*3) fmp (+100) (+100) b b 48

49 Functor Typeclss ghci> :t fmp (*2) fmp (*2) :: (Num, Functor f) => f -> f (*2) f fmp f ghci> :t fmp (replicte 3) fmp (replicte 3) :: (Functor f) => f -> f [] (replicte 3) [ ] fmp f f [ ] 49

50 Functor Typeclss ghci> fmp (replicte 3) [1,2,3,4] [[1,1,1],[2,2,2],[3,3,3],[4,4,4]] ghci> fmp (replicte 3) (Just 4) Just [4,4,4] ghci> fmp (replicte 3) (Right "blh") Right ["blh","blh","blh"] ghci> fmp (replicte 3) Nothing Nothing ghci> fmp (replicte 3) (Left "foo") Left "foo" 50

51 Functor Lws fmp id = id id id :: -> id x = x F fmp F instnce Functor Mybe where fmp func (Just x) = Just (func x) fmp func Nothing = Nothing F Just x id F Just x instnce Functor Mybe where Nothing Nothing fmp f (Just x) = Just (f x) fmp f Nothing = Nothing instnce Functor Mybe where fmp id (Just x) = Just (id x) fmp id Nothing = Nothing 51

52 Functor Typeclss ghci> fmp id (Just 3) Just 3 ghci> id (Just 3) Just 3 ghci> fmp id [1..5] [1,2,3,4,5] ghci> id [1..5] [1,2,3,4,5] ghci> fmp id [] [] ghci> fmp id Nothing Nothing 52

53 Functor Lws fmp (f. g) = fmp f. fmp g f. g fmp (f. g) F = fmp f (fmp g F) F fmp F g f F fmp F g f F fmp fmp F 53

54 Functor Lws fmp (f. g) = fmp f. fmp g fmp (f. g) F = fmp f (fmp g F) instnce Functor Mybe where fmp f (Just x) = Just (f x) fmp f Nothing = Nothing fmp (f. g) Nothing = Nothing fmp f (fmp g Nothing) = Nothing fmp (f. g) (Just x) = Just ((f. g) x) = Just (f (g x)) fmp f (fmp g (Just x)) = fmp f (Just (g x)) = Just (f (g x)) 54

55 References [1] ftp://ftp.geoinfo.tuwien.c.t/nvrtil/hskelltutoril.pdf [2]

Functor (1A) Young Won Lim 8/2/17

Functor (1A) Young Won Lim 8/2/17 Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published

More information

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example: cisc1110 fll 2010 lecture VI.2 cll y vlue function prmeters more on functions more on cll y vlue nd cll y reference pssing strings to functions returning strings from functions vrile scope glol vriles

More information

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays Objects nd Clsses Reference types nd their chrcteristics Clss Definition Constructors nd Object Cretion Specil objects: Strings nd Arrys OOAD 1999/2000 Cludi Niederée, Jochim W. Schmidt Softwre Systems

More information

10/9/2012. Operator is an operation performed over data at runtime. Arithmetic, Logical, Comparison, Assignment, Etc. Operators have precedence

10/9/2012. Operator is an operation performed over data at runtime. Arithmetic, Logical, Comparison, Assignment, Etc. Operators have precedence /9/22 P f Performing i Si Simple l Clcultions C l l ti with ith C#. Opertors in C# nd Opertor Precedence 2. Arithmetic Opertors 3. Logicl Opertors 4. Bitwise Opertors 5. Comprison Opertors 6. Assignment

More information

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure Lecture Overview Knowledge-bsed systems in Bioinformtics, MB6 Scheme lecture Procedurl bstrction Higher order procedures Procedures s rguments Procedures s returned vlues Locl vribles Dt bstrction Compound

More information

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications. 15-112 Fll 2018 Midterm 1 October 11, 2018 Nme: Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or

More information

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls Redings for Next Two Lectures Text CPSC 213 Switch Sttements, Understnding Pointers - 2nd ed: 3.6.7, 3.10-1st ed: 3.6.6, 3.11 Introduction to Computer Systems Unit 1f Dynmic Control Flow Polymorphism nd

More information

Maybe Monad (3B) Young Won Lim 1/3/18

Maybe Monad (3B) Young Won Lim 1/3/18 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Binary Relations (4B) Young Won Lim 5/15/17

Binary Relations (4B) Young Won Lim 5/15/17 Binry Reltions (4B) Copyright (c) 205 207 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version.2 or ny lter version

More information

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure

More information

Background Type Classes (1B) Young Won Lim 6/28/18

Background Type Classes (1B) Young Won Lim 6/28/18 Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

Unit 5 Vocabulary. A function is a special relationship where each input has a single output. MODULE 3 Terms Definition Picture/Exmple/Nottion 1 Function Nottion Function nottion is n efficient nd effective wy to write functions of ll types. This nottion llows you to identify the input vlue with

More information

CSE 401 Midterm Exam 11/5/10 Sample Solution

CSE 401 Midterm Exam 11/5/10 Sample Solution Question 1. egulr expressions (20 points) In the Ad Progrmming lnguge n integer constnt contins one or more digits, but it my lso contin embedded underscores. Any underscores must be preceded nd followed

More information

Relations (3A) Young Won Lim 3/15/18

Relations (3A) Young Won Lim 3/15/18 Reltions (A) Copyright (c) 05 08 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version. or ny lter version published

More information

Background Type Classes (1B) Young Won Lim 6/14/18

Background Type Classes (1B) Young Won Lim 6/14/18 Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Stained Glass Design. Teaching Goals:

Stained Glass Design. Teaching Goals: Stined Glss Design Time required 45-90 minutes Teching Gols: 1. Students pply grphic methods to design vrious shpes on the plne.. Students pply geometric trnsformtions of grphs of functions in order to

More information

Lists in Lisp and Scheme

Lists in Lisp and Scheme Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,

More information

L2-Python-Data-Structures

L2-Python-Data-Structures L2-Python-Dt-Structures Mrch 19, 2018 1 Principl built-in types in Python (Python ) numerics: int, flot, long, complex sequences: str, unicode, list, tuple, byterry, buffer, xrnge mppings: dict files:

More information

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers Mth Modeling Lecture 4: Lgrnge Multipliers Pge 4452 Mthemticl Modeling Lecture 4: Lgrnge Multipliers Lgrnge multipliers re high powered mthemticl technique to find the mximum nd minimum of multidimensionl

More information

Example: 2:1 Multiplexer

Example: 2:1 Multiplexer Exmple: 2:1 Multiplexer Exmple #1 reg ; lwys @( or or s) egin if (s == 1') egin = ; else egin = ; 1 s B. Bs 114 Exmple: 2:1 Multiplexer Exmple #2 Normlly lwys include egin nd sttements even though they

More information

5 Regular 4-Sided Composition

5 Regular 4-Sided Composition Xilinx-Lv User Guide 5 Regulr 4-Sided Composition This tutoril shows how regulr circuits with 4-sided elements cn be described in Lv. The type of regulr circuits tht re discussed in this tutoril re those

More information

Stack. A list whose end points are pointed by top and bottom

Stack. A list whose end points are pointed by top and bottom 4. Stck Stck A list whose end points re pointed by top nd bottom Insertion nd deletion tke plce t the top (cf: Wht is the difference between Stck nd Arry?) Bottom is constnt, but top grows nd shrinks!

More information

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example: Boxes nd Arrows There re two kinds of vriles in Jv: those tht store primitive vlues nd those tht store references. Primitive vlues re vlues of type long, int, short, chr, yte, oolen, doule, nd flot. References

More information

MIPS I/O and Interrupt

MIPS I/O and Interrupt MIPS I/O nd Interrupt Review Floting point instructions re crried out on seprte chip clled coprocessor 1 You hve to move dt to/from coprocessor 1 to do most common opertions such s printing, clling functions,

More information

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork MA1008 Clculus nd Liner Algebr for Engineers Course Notes for Section B Stephen Wills Deprtment of Mthemtics University College Cork s.wills@ucc.ie http://euclid.ucc.ie/pges/stff/wills/teching/m1008/ma1008.html

More information

EECS 281: Homework #4 Due: Thursday, October 7, 2004

EECS 281: Homework #4 Due: Thursday, October 7, 2004 EECS 28: Homework #4 Due: Thursdy, October 7, 24 Nme: Emil:. Convert the 24-bit number x44243 to mime bse64: QUJD First, set is to brek 8-bit blocks into 6-bit blocks, nd then convert: x44243 b b 6 2 9

More information

Monad (3A) Young Won Lim 8/9/17

Monad (3A) Young Won Lim 8/9/17 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Math 142, Exam 1 Information.

Math 142, Exam 1 Information. Mth 14, Exm 1 Informtion. 9/14/10, LC 41, 9:30-10:45. Exm 1 will be bsed on: Sections 7.1-7.5. The corresponding ssigned homework problems (see http://www.mth.sc.edu/ boyln/sccourses/14f10/14.html) At

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Maybe Monad (3B) Young Won Lim 12/21/17

Maybe Monad (3B) Young Won Lim 12/21/17 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Pointers and Arrays. More Pointer Examples. Pointers CS 217

Pointers and Arrays. More Pointer Examples. Pointers CS 217 Pointers nd Arrs CS 21 1 2 Pointers More Pointer Emples Wht is pointer A vrile whose vlue is the ddress of nother vrile p is pointer to vrile v Opertions &: ddress of (reference) *: indirection (dereference)

More information

PYTHON PROGRAMMING. The History of Python. Features of Python. This Course

PYTHON PROGRAMMING. The History of Python. Features of Python. This Course The History of Python PYTHON PROGRAMMING Dr Christin Hill 7 9 November 2016 Invented by Guido vn Rossum* t the Centrum Wiskunde & Informtic in Amsterdm in the erly 1990s Nmed fter Monty Python s Flying

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence

More information

Spring 2018 Midterm Exam 1 March 1, You may not use any books, notes, or electronic devices during this exam.

Spring 2018 Midterm Exam 1 March 1, You may not use any books, notes, or electronic devices during this exam. 15-112 Spring 2018 Midterm Exm 1 Mrch 1, 2018 Nme: Andrew ID: Recittion Section: You my not use ny books, notes, or electronic devices during this exm. You my not sk questions bout the exm except for lnguge

More information

Theory of Computation CSE 105

Theory of Computation CSE 105 $ $ $ Theory of Computtion CSE 105 Regulr Lnguges Study Guide nd Homework I Homework I: Solutions to the following problems should be turned in clss on July 1, 1999. Instructions: Write your nswers clerly

More information

Engineer To Engineer Note

Engineer To Engineer Note Engineer To Engineer Note EE-188 Technicl Notes on using Anlog Devices' DSP components nd development tools Contct our technicl support by phone: (800) ANALOG-D or e-mil: dsp.support@nlog.com Or visit

More information

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID: Fll term 2012 KAIST EE209 Progrmming Structures for EE Mid-term exm Thursdy Oct 25, 2012 Student's nme: Student ID: The exm is closed book nd notes. Red the questions crefully nd focus your nswers on wht

More information

a(e, x) = x. Diagrammatically, this is encoded as the following commutative diagrams / X

a(e, x) = x. Diagrammatically, this is encoded as the following commutative diagrams / X 4. Mon, Sept. 30 Lst time, we defined the quotient topology coming from continuous surjection q : X! Y. Recll tht q is quotient mp (nd Y hs the quotient topology) if V Y is open precisely when q (V ) X

More information

Fall 2017 Midterm Exam 1 October 19, You may not use any books, notes, or electronic devices during this exam.

Fall 2017 Midterm Exam 1 October 19, You may not use any books, notes, or electronic devices during this exam. 15-112 Fll 2017 Midterm Exm 1 October 19, 2017 Nme: Andrew ID: Recittion Section: You my not use ny books, notes, or electronic devices during this exm. You my not sk questions bout the exm except for

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS COMPUTATION & LOGIC Sturdy st April 7 : to : INSTRUCTIONS TO CANDIDATES This is tke-home exercise. It will not

More information

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays COMPSCI 5 SS Principles of Computer Science Arrys & Multidimensionl Arrys Agend & Reding Agend Arrys Creting & Using Primitive & Reference Types Assignments & Equlity Pss y Vlue & Pss y Reference Copying

More information

Introduction To Files In Pascal

Introduction To Files In Pascal Why other With Files? Introduction To Files In Pscl Too much informtion to input ll t once The informtion must be persistent (RAM is voltile) Etc. In this section of notes you will lern how to red from

More information

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex Long Quiz2 45mins Nme: Personl Numer: Prolem. (20pts) Here is n Tle of Perl Regulr Ex Chrcter Description. single chrcter \s whitespce chrcter (spce, t, newline) \S non-whitespce chrcter \d digit (0-9)

More information

INTRODUCTION TO SIMPLICIAL COMPLEXES

INTRODUCTION TO SIMPLICIAL COMPLEXES INTRODUCTION TO SIMPLICIAL COMPLEXES CASEY KELLEHER AND ALESSANDRA PANTANO 0.1. Introduction. In this ctivity set we re going to introduce notion from Algebric Topology clled simplicil homology. The min

More information

vcloud Director Service Provider Admin Portal Guide vcloud Director 9.1

vcloud Director Service Provider Admin Portal Guide vcloud Director 9.1 vcloud Director Service Provider Admin Portl Guide vcloud Director 9. vcloud Director Service Provider Admin Portl Guide You cn find the most up-to-dte technicl documenttion on the VMwre website t: https://docs.vmwre.com/

More information

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards A Tutology Checker loosely relted to Stålmrck s Algorithm y Mrtin Richrds mr@cl.cm.c.uk http://www.cl.cm.c.uk/users/mr/ University Computer Lortory New Museum Site Pemroke Street Cmridge, CB2 3QG Mrtin

More information

The Basic Properties of the Integral

The Basic Properties of the Integral The Bsic Properties of the Integrl When we compute the derivtive of complicted function, like + sin, we usull use differentition rules, like d [f()+g()] d f()+ d g(), to reduce the computtion d d d to

More information

Fig.1. Let a source of monochromatic light be incident on a slit of finite width a, as shown in Fig. 1.

Fig.1. Let a source of monochromatic light be incident on a slit of finite width a, as shown in Fig. 1. Answer on Question #5692, Physics, Optics Stte slient fetures of single slit Frunhofer diffrction pttern. The slit is verticl nd illuminted by point source. Also, obtin n expression for intensity distribution

More information

Improper Integrals. October 4, 2017

Improper Integrals. October 4, 2017 Improper Integrls October 4, 7 Introduction We hve seen how to clculte definite integrl when the it is rel number. However, there re times when we re interested to compute the integrl sy for emple 3. Here

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5 CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,

More information

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits Systems I Logic Design I Topics Digitl logic Logic gtes Simple comintionl logic circuits Simple C sttement.. C = + ; Wht pieces of hrdwre do you think you might need? Storge - for vlues,, C Computtion

More information

Solutions to Math 41 Final Exam December 12, 2011

Solutions to Math 41 Final Exam December 12, 2011 Solutions to Mth Finl Em December,. ( points) Find ech of the following its, with justifiction. If there is n infinite it, then eplin whether it is or. ( ) / ln() () (5 points) First we compute the it:

More information

INDIAN COMMUNITY SCHOOL INFORMATICS PRACTICES 2012

INDIAN COMMUNITY SCHOOL INFORMATICS PRACTICES 2012 INDIAN COMMUNITY SCHOOL INFORMATICS PRACTICES 0. Write corresponding C ++ expression for the following mthemticl expression: i) (-b) + (c-d) ii) e x x. Write C++ expression for the following: ) All possible

More information

MATH 25 CLASS 5 NOTES, SEP

MATH 25 CLASS 5 NOTES, SEP MATH 25 CLASS 5 NOTES, SEP 30 2011 Contents 1. A brief diversion: reltively prime numbers 1 2. Lest common multiples 3 3. Finding ll solutions to x + by = c 4 Quick links to definitions/theorems Euclid

More information

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) Numbers nd Opertions, Algebr, nd Functions 45. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) In sequence of terms involving eponentil growth, which the testing service lso clls geometric

More information

Matrices and Systems of Equations

Matrices and Systems of Equations Mtrices Mtrices nd Sstems of Equtions A mtri is rectngulr rr of rel numbers. CHAT Pre-Clculus Section 8. m m m............ n n n mn We will use the double subscript nottion for ech element of the mtri.

More information

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

In the last lecture, we discussed how valid tokens may be specified by regular expressions. LECTURE 5 Scnning SYNTAX ANALYSIS We know from our previous lectures tht the process of verifying the syntx of the progrm is performed in two stges: Scnning: Identifying nd verifying tokens in progrm.

More information

2014 Haskell January Test Regular Expressions and Finite Automata

2014 Haskell January Test Regular Expressions and Finite Automata 0 Hskell Jnury Test Regulr Expressions nd Finite Automt This test comprises four prts nd the mximum mrk is 5. Prts I, II nd III re worth 3 of the 5 mrks vilble. The 0 Hskell Progrmming Prize will be wrded

More information

binary trees, expression trees

binary trees, expression trees COMP 250 Lecture 21 binry trees, expression trees Oct. 27, 2017 1 Binry tree: ech node hs t most two children. 2 Mximum number of nodes in binry tree? Height h (e.g. 3) 3 Mximum number of nodes in binry

More information

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών ΕΠΛ323 - Θωρία και Πρακτική Μταγλωττιστών Lecture 3 Lexicl Anlysis Elis Athnsopoulos elisthn@cs.ucy.c.cy Recognition of Tokens if expressions nd reltionl opertors if è if then è then else è else relop

More information

COMMON HALF YEARLY EXAMINATION DECEMBER 2018

COMMON HALF YEARLY EXAMINATION DECEMBER 2018 li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net.pds.pds COMMON HALF YEARLY EXAMINATION DECEMBER 2018 STD : XI SUBJECT: COMPUTER SCIENCE

More information

a < a+ x < a+2 x < < a+n x = b, n A i n f(x i ) x. i=1 i=1

a < a+ x < a+2 x < < a+n x = b, n A i n f(x i ) x. i=1 i=1 Mth 33 Volume Stewrt 5.2 Geometry of integrls. In this section, we will lern how to compute volumes using integrls defined by slice nlysis. First, we recll from Clculus I how to compute res. Given the

More information

Fall 2018 Midterm 2 November 15, 2018

Fall 2018 Midterm 2 November 15, 2018 Nme: 15-112 Fll 2018 Midterm 2 November 15, 2018 Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or

More information

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 21 Sndiwy Fong Tody's Topics Homework 8 Review Optionl Homework 9 (mke up on Homework 7) Homework 8 Review Question1: write Prolog regulr grmmr for the following lnguge:

More information

Data sharing in OpenMP

Data sharing in OpenMP Dt shring in OpenMP Polo Burgio polo.burgio@unimore.it Outline Expressing prllelism Understnding prllel threds Memory Dt mngement Dt cluses Synchroniztion Brriers, locks, criticl sections Work prtitioning

More information

Ray surface intersections

Ray surface intersections Ry surfce intersections Some primitives Finite primitives: polygons spheres, cylinders, cones prts of generl qudrics Infinite primitives: plnes infinite cylinders nd cones generl qudrics A finite primitive

More information

Pointwise convergence need not behave well with respect to standard properties such as continuity.

Pointwise convergence need not behave well with respect to standard properties such as continuity. Chpter 3 Uniform Convergence Lecture 9 Sequences of functions re of gret importnce in mny res of pure nd pplied mthemtics, nd their properties cn often be studied in the context of metric spces, s in Exmples

More information

How to Design REST API? Written Date : March 23, 2015

How to Design REST API? Written Date : March 23, 2015 Visul Prdigm How Design REST API? Turil How Design REST API? Written Dte : Mrch 23, 2015 REpresenttionl Stte Trnsfer, n rchitecturl style tht cn be used in building networked pplictions, is becoming incresingly

More information

CMSC 331 First Midterm Exam

CMSC 331 First Midterm Exam 0 00/ 1 20/ 2 05/ 3 15/ 4 15/ 5 15/ 6 20/ 7 30/ 8 30/ 150/ 331 First Midterm Exm 7 October 2003 CMC 331 First Midterm Exm Nme: mple Answers tudent ID#: You will hve seventy-five (75) minutes to complete

More information

CSC 372, Spring 2014 Assignment 2 Due: Wednesday, February 26 at 23:00

CSC 372, Spring 2014 Assignment 2 Due: Wednesday, February 26 at 23:00 ASSIGNMENT-WIDE RESTRICTIONS There re two ssignment-wide restrictions: CSC 372, Spring 2014 Assignment 2 Due: Wednesdy, Februry 26 t 23:00 1. The only module you my use is Dt.Chr. 2. Except for problem

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Writing Classes

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Writing Classes Introduction to Computer Science, Shimon Schocken, IDC Herzliy Lecture 5.1-5.2 Writing Clsses Writing Clsses, Shimon Schocken IDC Herzliy, www.ro2cs.com slide 1 Clsses Two viewpos on es: Client view: how

More information

Chapter 2 Sensitivity Analysis: Differential Calculus of Models

Chapter 2 Sensitivity Analysis: Differential Calculus of Models Chpter 2 Sensitivity Anlysis: Differentil Clculus of Models Abstrct Models in remote sensing nd in science nd engineering, in generl re, essentilly, functions of discrete model input prmeters, nd/or functionls

More information

ASTs, Regex, Parsing, and Pretty Printing

ASTs, Regex, Parsing, and Pretty Printing ASTs, Regex, Prsing, nd Pretty Printing CS 2112 Fll 2016 1 Algeric Expressions To strt, consider integer rithmetic. Suppose we hve the following 1. The lphet we will use is the digits {0, 1, 2, 3, 4, 5,

More information

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION CIS 1068 Progrm Design nd Astrction Spring2015 Midterm Exm 1 Nme SOLUTION Pge Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Totl 100 1 P ge 1. Progrm Trces (41 points, 50 minutes) Answer the

More information

File Manager Quick Reference Guide. June Prepared for the Mayo Clinic Enterprise Kahua Deployment

File Manager Quick Reference Guide. June Prepared for the Mayo Clinic Enterprise Kahua Deployment File Mnger Quick Reference Guide June 2018 Prepred for the Myo Clinic Enterprise Khu Deployment NVIGTION IN FILE MNGER To nvigte in File Mnger, users will mke use of the left pne to nvigte nd further pnes

More information

CSEP 573 Artificial Intelligence Winter 2016

CSEP 573 Artificial Intelligence Winter 2016 CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch

More information

A Tutorial Introduction to the Lambda Calculus

A Tutorial Introduction to the Lambda Calculus rxiv:1503.09060v1 [cs.lo] 28 Mr 2015 A Tutoril Introduction to the Lmbd Clculus Rul Rojs Freie Universität Berlin Version 2.0, 2015 Abstrct This pper is concise nd pinless introduction to the λ-clculus.

More information

Monad Background (3A) Young Won Lim 11/20/17

Monad Background (3A) Young Won Lim 11/20/17 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

From Dependencies to Evaluation Strategies

From Dependencies to Evaluation Strategies From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute

More information

Reducing a DFA to a Minimal DFA

Reducing a DFA to a Minimal DFA Lexicl Anlysis - Prt 4 Reducing DFA to Miniml DFA Input: DFA IN Assume DFA IN never gets stuck (dd ded stte if necessry) Output: DFA MIN An equivlent DFA with the minimum numer of sttes. Hrry H. Porter,

More information

Virtual Machine (Part I)

Virtual Machine (Part I) Hrvrd University CS Fll 2, Shimon Schocken Virtul Mchine (Prt I) Elements of Computing Systems Virtul Mchine I (Ch. 7) Motivtion clss clss Min Min sttic sttic x; x; function function void void min() min()

More information

12-B FRACTIONS AND DECIMALS

12-B FRACTIONS AND DECIMALS -B Frctions nd Decimls. () If ll four integers were negtive, their product would be positive, nd so could not equl one of them. If ll four integers were positive, their product would be much greter thn

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009 Deprtment of Computer cience Columbi University mple Midterm olutions COM W4115 Progrmming Lnguges nd Trnsltors Mondy, October 12, 2009 Closed book, no ids. ch question is worth 20 points. Question 5(c)

More information

Integration. October 25, 2016

Integration. October 25, 2016 Integrtion October 5, 6 Introduction We hve lerned in previous chpter on how to do the differentition. It is conventionl in mthemtics tht we re supposed to lern bout the integrtion s well. As you my hve

More information

Introduction to Julia for Bioinformatics

Introduction to Julia for Bioinformatics Introduction to Juli for Bioinformtics This introduction ssumes tht you hve bsic knowledge of some scripting lnguge nd provides n exmple of the Juli syntx. Continuous Assessment Problems In this course

More information

Engineer-to-Engineer Note

Engineer-to-Engineer Note Engineer-to-Engineer Note EE-069 Technicl notes on using Anlog Devices DSPs, processors nd development tools Visit our Web resources http://www.nlog.com/ee-notes nd http://www.nlog.com/processors or e-mil

More information

Introduction to Algebra

Introduction to Algebra INTRODUCTORY ALGEBRA Mini-Leture 1.1 Introdution to Alger Evlute lgeri expressions y sustitution. Trnslte phrses to lgeri expressions. 1. Evlute the expressions when =, =, nd = 6. ) d) 5 10. Trnslte eh

More information

6.2 Volumes of Revolution: The Disk Method

6.2 Volumes of Revolution: The Disk Method mth ppliction: volumes by disks: volume prt ii 6 6 Volumes of Revolution: The Disk Method One of the simplest pplictions of integrtion (Theorem 6) nd the ccumultion process is to determine so-clled volumes

More information

CMPSC 470: Compiler Construction

CMPSC 470: Compiler Construction CMPSC 47: Compiler Construction Plese complete the following: Midterm (Type A) Nme Instruction: Mke sure you hve ll pges including this cover nd lnk pge t the end. Answer ech question in the spce provided.

More information

Migrating vrealize Automation to 7.3 or March 2018 vrealize Automation 7.3

Migrating vrealize Automation to 7.3 or March 2018 vrealize Automation 7.3 Migrting vrelize Automtion to 7.3 or 7.3.1 15 Mrch 2018 vrelize Automtion 7.3 You cn find the most up-to-dte technicl documenttion on the VMwre website t: https://docs.vmwre.com/ If you hve comments bout

More information

Creating Flexible Interfaces. Friday, 24 April 2015

Creating Flexible Interfaces. Friday, 24 April 2015 Creting Flexible Interfces 1 Requests, not Objects Domin objects re esy to find but they re not t the design center of your ppliction. Insted, they re trp for the unwry. Sequence digrms re vehicle for

More information

Compilers Spring 2013 PRACTICE Midterm Exam

Compilers Spring 2013 PRACTICE Midterm Exam Compilers Spring 2013 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs

More information

CS 130 : Computer Systems - II. Shankar Balachandran Dept. of Computer Science & Engineering IIT Madras

CS 130 : Computer Systems - II. Shankar Balachandran Dept. of Computer Science & Engineering IIT Madras CS 3 : Computer Systems - II Shnkr Blchndrn (shnkr@cse.iitm.c.in) Dept. of Computer Science & Engineering IIT Mdrs Recp Differentite Between s nd s Truth Tbles b AND b OR NOT September 4, 27 Introduction

More information

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or

Operator Precedence. Java CUP. E E + T T T * P P P id id id. Does a+b*c mean (a+b)*c or Opertor Precedence Most progrmming lnguges hve opertor precedence rules tht stte the order in which opertors re pplied (in the sence of explicit prentheses). Thus in C nd Jv nd CSX, +*c mens compute *c,

More information

ECE 468/573 Midterm 1 September 28, 2012

ECE 468/573 Midterm 1 September 28, 2012 ECE 468/573 Midterm 1 September 28, 2012 Nme:! Purdue emil:! Plese sign the following: I ffirm tht the nswers given on this test re mine nd mine lone. I did not receive help from ny person or mteril (other

More information

x )Scales are the reciprocal of each other. e

x )Scales are the reciprocal of each other. e 9. Reciprocls A Complete Slide Rule Mnul - eville W Young Chpter 9 Further Applictions of the LL scles The LL (e x ) scles nd the corresponding LL 0 (e -x or Exmple : 0.244 4.. Set the hir line over 4.

More information

SIMPLIFYING ALGEBRA PASSPORT.

SIMPLIFYING ALGEBRA PASSPORT. SIMPLIFYING ALGEBRA PASSPORT www.mthletics.com.u This booklet is ll bout turning complex problems into something simple. You will be ble to do something like this! ( 9- # + 4 ' ) ' ( 9- + 7-) ' ' Give

More information