Az előző rész tartalmából...

Size: px
Start display at page:

Download "Az előző rész tartalmából..."

Transcription

1 Az előző rész tartalmából...

2 [2..26]

3 Programozás burritokkal [3..26]

4 Programozás monádokkal programstruktúrálás type IO a = World -> (a, World) -- putstr :: String -> IO () -- getline :: IO String (>>=) :: IO a -> (a -> IO b) -> IO b (f >>= g) w = (g x) w where (x, w ) = f w (>>) :: IO a -> IO b -> IO b f >> g = f >>= \_ -> g main :: IO () main = putstr "Provide me a word> " >> getline >>= \s -> if (s == reverse s) then putstr "A palindrome." else putstr "Not a palindrome." [4..26]

5 Programozás monádokkal a Monad típusosztály {-# LANGUAGE KindSignatures #-} -- Control.Monad class Monad (m :: * -> *) where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b (>>) :: m a -> m b -> m b x >> f = x >>= \_ -> f fail :: String -> m a fail s = error s (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c) f >=> g = \x -> f x >>= g Monádtörvények: return >=> f === f f >=> return === f (f >=> g) >=> h === f >=> (g >=> h) + run függvény [5..26]

6 Programozás monádokkal a do szintaktika Átírási szabályok: do { e1; e2 } --> e1 >> do { e2 } do { p <- e1; e2 } --> e1 >>= \x -> case x of p -> do { e2 } _ -> fail "error" do { let p = e1; e2 } --> let p = e1 in do { e2 } do { e } --> e Például: do { do x <- f; x <- f f >>= \x -> y <- g; y <- g g >>= \y -> z <- h; --> z <- h --> h >>= \z -> let t = (x,y,z); let t = (x,y,z) let t = (x,y,z) in return t return t return t } [6..26]

7 Intermezzo

8 Applicative...?! Prelude> :load Identity.hs [1 of 1] Compiling Main ( Identity.hs, interpreted ) Identity.hs:6:10: Warning: Identity is an instance of Monad but not Applicative - this will become an error in GHC 7.10, under the Applicative-Monad Proposal. Ok, modules loaded: Main. Minden Monad ideális esetben Applicative Functor: class Functor (f :: * -> *) where -- Data.Functor fmap :: (a -> b) -> f a -> f b -- Control.Applicative class (Functor f) => Applicative (f :: * -> *) where pure :: a -> f a (<*>) :: f (a -> b) -> f a -> f b instance (Monad m) => Functor m where f fmap x = pure f <*> x instance (Monad m) => Applicative m where pure x = return x af <*> ax = do { f <- af; x <- ax; return (f x) } [8..26]

9 Következő felvonás

10 A State monád (intuíció) type State s a = s -> (a, s) -- (s -> (a, s)) -> (a -> (s -> (b, s))) -> (s -> (b, s)) (>>=) :: State s a -> (a -> State s b) -> State s b (x >>= f) s = (f x ) s where (x, s ) = x s -- a -> (s -> (a, s)) return :: a -> State s a (return x) s = (x, s) -- s -> (s, s) get :: State s s (get) s = (s, s) -- s -> ((), s) put :: s -> State s () (put x) s = ((), x) -- (s -> (a, s)) -> s -> (a, s)) runstate :: State s a -> s -> (a, s)) runstate f s = f s [10..26]

11 A State monád (definíció) -- Control.Monad.State data State s a = S (s -> (a, s)) runstate :: State s a -> s -> (a, s) runstate (S f) x = f x instance Monad (State s) where return x = S (\s -> (x,s)) x >>= f = S (\s -> let (x, s ) = runstate x s in runstate (f x ) s ) get :: State s s get = S (\s -> (s, s)) put :: s -> State s () put x = S (\_ -> ((), x)) [11..26]

12 A State monád (példa) data Tree a = Node a (Tree a) (Tree a) Leaf deriving Show numbertree :: (Eq a) => Tree a -> Tree Int numbertree t = fst (runstate (numbertreem t) []) numbertreem :: (Eq a) => Tree a -> State [a] (Tree Int) numbertreem Leaf = return Leaf numbertreem (Node x lt rt) = do table <- get let (table, pos) = case (Data.List.findIndex (== x) table) of put table lt <- numbertreem lt rt <- numbertreem rt return (Node pos lt rt ) Just i -> (table, i) _ -> (table ++ [x], length table) [12..26]

13 A Writer monád (egyszerűsített) -- Control.Monad.Writer data Writer w a = W (a, w) runwriter :: (Monoid w) => Writer w a -> (a, w) runwriter (W (x, w)) = (x, w) instance (Monoid w) => Monad (Writer w) where return x = W (x, mempty) x >>= f = W (let (x, w) = runwriter x in let (x, w ) = runwriter (f x ) in (x, w <> w )) tell :: (Monoid w) => w -> Writer w () tell x = W ((), x) censor :: (Monoid w) => (w -> w) -> Writer w a -> Writer w a censor f (W (x, w)) = W (x, f w) [13..26]

14 A Writer monád (Monoid) -- Data.Monoid class Monoid (a :: *) where mempty :: a mappend :: a -> a -> a (<>) :: (Monoid a) => a -> a -> a -- GHC 7.6+ (<>) = mappend Monoidtörvények: mempty <> x === x x <> mempty === x x <> (y <> z) === (x <> y) <> z mconcat === foldr (<>) mempty Például: instance Monoid [a] where mempty = [] mappend = (++) -- data Sum a = Sum a instance (Num a) => Monoid (Sum a) where mempty = Sum 0 (Sum x) mappend (Sum y) = Sum (x + y) [14..26]

15 A Writer monád (példa) gcdwithlog :: Int -> Int -> (Int, [String]) gcdwithlog x y = runwriter (censor reverse (gcdwithlogm x y)) gcdwithlogm :: Int -> Int -> Writer [String] Int gcdwithlogm x y y == 0 = do tell ["Finished with " ++ show x] return x gcdwithlogm x y = do result <- gcdwithlogm y (x mod y) let msg = show x ++ " mod " ++ show y ++ " = " ++ show (x mod y) tell [msg] return result [15..26]

16 Monádtranszformátorok

17 Motiváció Monádok kombinációja countentries :: FilePath -> K () countentries path = f path 0 where f p n = do deepestreached <- get when (deepestreached < n) (put n) c <- liftio (System.Directory.getDirectoryContents p) let contents = filter ( notelem [".", ".."]) c tell [(p, length contents)] form_ contents (\name -> do let newname = p ++ "/" ++ name isdir <- liftio (System.Directory.doesDirectoryExist newname) maxdepth <- ask when (isdir && (n < maxdepth)) (f newname (n + 1))) type S = Int type C = Int type K = ReaderT C (StateT S (WriterT [(FilePath,Int)] IO)) runstack :: K a -> Int -> IO ((a,s),[(filepath,int)]) runstack k max = runwritert (runstatet (runreadert k c) s) where (s, c) = (0, max) [17..26]

18 Monádok rétegelése (stacking) [18..26]

19 Részletek A MonadTrans és MonadIO osztályok -- Control.Monad.Trans class MonadTrans (t :: (* -> *) -> * -> *) where lift :: Monad m => m a -> t m a Transzformátortörvények: lift. return === return lift (x >>= f) === lift x >>= (lift. f) Az IO esetén ellenben: -- Control.Monad.IO.Class class Monad m => MonadIO (m :: * -> *) where liftio :: IO a -> m a instance MonadIO IO where liftio m = m Adaptált törvények: liftio. return === return liftio (x >>= f) === liftio x >>= (liftio. f) [19..26]

20 A ReaderT transzformátor (egyszerűsített) {-# LANGUAGE KindSignatures, TypeFamilies, FlexibleContexts #-} class (Monad m) => MonadReader (m :: * -> *) where type EnvType m -- "associated type (synonym)" ask :: m (EnvType m) data ReaderT e m a = RT (e -> m a) runreadert :: ReaderT e m a -> e -> m a runreadert (RT t) e = t e type Reader e = ReaderT e Identity runreader :: Reader e a -> e -> a runreader m x = runidentity (runreadert m x) instance (Monad m) => Monad (ReaderT e m) where return x = lift (return x) x >>= f = RT (\e -> do x <- runreadert x e runreadert (f x ) e) [20..26]

21 A ReaderT transzformátor (egyszerűsített, folytatás) instance MonadTrans (ReaderT e) where lift m = RT (\e -> m) instance (Monad m) => MonadReader (ReaderT e m) where type EnvType (ReaderT e m) = e -- ask :: (ReaderT e m) e ask = RT (\e -> return e) instance (MonadState m) => MonadState (ReaderT e m) where type StateType (ReaderT e m) = StateType m -- get :: m (StateType m) get = lift get -- put :: (StateType m) -> m () put s = lift (put s) instance (MonadWriter m) => MonadWriter (ReaderT e m) where type WriterType (ReaderT e m) = WriterType m -- tell :: (WriterType m) -> m () tell w = lift (tell w) -- censor :: (WriterType m -> WriterType m) -> m a -> m a censor f m = RT (\e -> do let m = runreadert m e censor f m ) instance (MonadIO m) => MonadIO (ReaderT e m) where liftio m = lift (liftio m) [21..26]

22 A StateT transzformátor (egyszerűsített) class (Monad m) => MonadState m where type StateType m get :: m (StateType m) put :: (StateType m) -> m () data StateT s m a = ST (s -> m (a, s)) runstatet :: StateT s m a -> s -> m (a, s) runstatet (ST t) s = t s type State s = StateT s Identity runstate :: State s a -> s -> (a, s) runstate m x = runidentity (runstatet m x) instance (Monad m) => Monad (StateT s m) where return x = ST (\s -> return (x, s)) x >>= f = ST (\s -> do (x, s ) <- runstatet x s runstatet (f x ) s ) [22..26]

23 A StateT transzformátor (egyszerűsített, folytatás) instance MonadTrans (StateT s) where lift m = ST (\s -> do x <- m return (x, s)) instance (Monad m) => MonadState (StateT s m) where type StateType (StateT s m) = s get = ST (\s -> return (s,s)) put s = ST (\_ -> return ((),s)) instance (MonadReader m) => MonadReader (StateT s m) where type EnvType (StateT s m) = EnvType m ask = lift ask instance (MonadWriter m) => MonadWriter (StateT s m) where type WriterType (StateT s m) = WriterType m tell w = lift (tell w) censor f m = ST (\s -> do let m = runstatet m s censor f m ) instance (MonadIO m) => MonadIO (StateT s m) where liftio m = lift (liftio m) [23..26]

24 A WriterT transzformátor (egyszerűsített) class (Monoid (WriterType m), Monad m) => MonadWriter m where type WriterType m tell :: (WriterType m) -> m () censor :: (WriterType m -> WriterType m) -> m a -> m a data WriterT w m a = WT (m (a,w)) runwritert :: WriterT w m a -> m (a, w) runwritert (WT m) = m type Writer a = WriterT a Identity runwriter :: Writer w a -> (a, w) runwriter m = runidentity (runwritert m) instance (Monoid w, Monad m) => Monad (WriterT w m) where return x = WT (return (x, mempty)) x >>= f = WT (do (x, w) <- runwritert x (x, w ) <- runwritert (f x ) return (x, w <> w )) [24..26]

25 A WriterT transzformátor (egyszerűsített, folytatás) instance (Monoid w) => MonadTrans (WriterT w) where lift m = WT (do x <- m return (x, mempty)) instance (Monoid w, MonadState m) => MonadState (WriterT w m) where type StateType (WriterT w m) = StateType m get = lift get put s = lift (put s) instance (Monoid w, MonadReader m) => MonadReader (WriterT w m) where type EnvType (WriterT w m) = EnvType m ask = lift ask instance (Monoid w, Monad m) => MonadWriter (WriterT w m) where type WriterType (WriterT w m) = w tell w = WT (return ((), w)) censor f m = WT (do (x, w) <- runwritert m return (x, f w)) instance (Monoid w, MonadIO m) => MonadIO (WriterT w m) where liftio m = lift (liftio m) [25..26]

26 A monádrétegek sorrendje (példa) stack :: (MonadState Int m, MonadWriter [String] m, MonadError String m) => m () stack = do r <- get tell ["Hello!"] throwerror "Error!" tell ["Value: " ++ show r] put (r + 1) type A = ErrorT String (WriterT [String] (State Int)) type B = StateT Int (WriterT [String] (Either String)) stacka :: A () stacka = stack stackb :: B () stackb = stack runa = runstate (runwritert (runerrort stacka)) 0 runb = runwritert (runstatet stackb 0) [26..26]

Embedding effect systems in Haskell

Embedding effect systems in Haskell Embedding effect systems in Haskell Dominic Orchard Tomas Petricek Computer Laboratory, University of Cambridge firstname.lastname@cl.cam.ac.uk Abstract Monads are now an everyday tool in functional programming

More information

Programming and Reasoning with Algebraic Effects and Dependent Types

Programming and Reasoning with Algebraic Effects and Dependent Types Programming and Reasoning with Algebraic Effects and Dependent Types Edwin C. Brady School of Computer Science, University of St Andrews, St Andrews, Scotland. Email: ecb10@st-andrews.ac.uk Abstract One

More information

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID:

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID: CS177 MIDTERM 2 PRACTICE EXAM SOLUTION Name: Student ID: This practice exam is due the day of the midterm 2 exam. The solutions will be posted the day before the exam but we encourage you to look at the

More information

Gluing things together with Haskell. Neil Mitchell http://nmitchell.co.uk/

Gluing things together with Haskell. Neil Mitchell http://nmitchell.co.uk/ Gluing things together with Haskell Neil Mitchell http://nmitchell.co.uk/ Code Elegantly designed Build system Test harness Continuous integration Release bundling Installer generator Release distribution

More information

Programming and Reasoning with Side-Effects in IDRIS

Programming and Reasoning with Side-Effects in IDRIS Programming and Reasoning with Side-Effects in IDRIS Edwin Brady 19th October 2014 Contents 1 Introduction 3 1.1 Hello world............................................. 3 1.2 Outline................................................

More information

UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions.

UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions. UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING Answer THREE Questions. The Use of Electronic Calculators: is NOT Permitted. -1- Answer Question

More information

Formal Methods for Software Development

Formal Methods for Software Development Formal Methods for Software Development Till Mossakowski, Lutz Schröder 03./08.11.2004 2 Monadic QuickCheck extension of QuickCheck for monadic (= imperative) programs specifications are equations between

More information

Cloud Haskell. Distributed Programming with. Andres Löh. 14 June 2013, Big Tech Day 6 Copyright 2013 Well-Typed LLP. .Well-Typed

Cloud Haskell. Distributed Programming with. Andres Löh. 14 June 2013, Big Tech Day 6 Copyright 2013 Well-Typed LLP. .Well-Typed Distributed Programming with Cloud Haskell Andres Löh 14 June 2013, Big Tech Day 6 Copyright 2013 Well-Typed LLP Well-Typed The Haskell Consultants Overview Introduction Haskell Cloud Haskell Communication

More information

Extensible Effects An Alternative to Monad Transformers

Extensible Effects An Alternative to Monad Transformers Extensible Effects An Alternative to Monad Transformers Oleg Kiselyov Amr Sabry Cameron Swords Haskell Symposium 2013 Boston, MA Sep 23, 2013 We design and implement a library that solves the long-standing

More information

Denotational design with type class morphisms (extended version)

Denotational design with type class morphisms (extended version) LambdaPix technical report 2009-01, March 2009 (minor revisions February 15, 2011) 1 Denotational design with type class morphisms (extended version) Conal Elliott LambdaPix conal@conal.net Abstract Type

More information

Teaching Statement Richard A. Eisenberg

Teaching Statement Richard A. Eisenberg Teaching Statement Richard A. Eisenberg Computer science strikes me as beautiful: how the rules of logic can be used to prove the undecidability of the halting problem, how the magic wand of induction

More information

Fuld Skolerapport for Søhusskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 9. med reference Tilsvarende klassetrin i kommunen

Fuld Skolerapport for Søhusskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 9. med reference Tilsvarende klassetrin i kommunen Side 1 af 41 Side 2 af 41 Side 3 af 41 Side 4 af 41 Side 5 af 41 Side 6 af 41 Side 7 af 41 Side 8 af 41 Side 9 af 41 Side 10 af 41 Side 11 af 41 Side 12 af 41 Side 13 af 41 Side 14 af 41 Side 15 af 41

More information

Fuld Skolerapport for Hunderupskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 7. med reference Tilsvarende klassetrin i kommunen

Fuld Skolerapport for Hunderupskolen, i Odense kommune, for skoleår 2013/2014 for klassetrin(ene) 7. med reference Tilsvarende klassetrin i kommunen Side 1 af 43 Side 2 af 43 Side 3 af 43 Side 4 af 43 Side 5 af 43 Side 6 af 43 Side 7 af 43 Side 8 af 43 Side 9 af 43 Side 10 af 43 Side 11 af 43 Side 12 af 43 Side 13 af 43 Side 14 af 43 Side 15 af 43

More information

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr; 50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)

More information

Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006

Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006 Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006 Final Examination January 24 th, 2006 NAME: Please read all instructions carefully before start answering. The exam will be

More information

When a variable is assigned as a Process Initialization variable its value is provided at the beginning of the process.

When a variable is assigned as a Process Initialization variable its value is provided at the beginning of the process. In this lab you will learn how to create and use variables. Variables are containers for data. Data can be passed into a job when it is first created (Initialization data), retrieved from an external source

More information

Sample Questions Csci 1112 A. Bellaachia

Sample Questions Csci 1112 A. Bellaachia Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k

More information

Introduction FUNCTIONAL PROGRAMMING. The Problem. The Solution. Graham Hutton. Lecture 9 - Interactive Programs. keyboard. screen

Introduction FUNCTIONAL PROGRAMMING. The Problem. The Solution. Graham Hutton. Lecture 9 - Interactive Programs. keyboard. screen FUNCTIONAL PROGRAMMING Introduction To date, we have seen how Haskell can be used to write batch programs that take all their inputs at the start and give all their outputs at the end. Graham Hutton inputs

More information

Testing and Tracing Lazy Functional Programs using QuickCheck and Hat

Testing and Tracing Lazy Functional Programs using QuickCheck and Hat Testing and Tracing Lazy Functional Programs using QuickCheck and Hat Koen Claessen 1, Colin Runciman 2, Olaf Chitil 2, John Hughes 1, and Malcolm Wallace 2 1 Chalmers University of Technology, Sweden

More information

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur Module 10 Coding and Testing Lesson 26 Debugging, Integration and System Testing Specific Instructional Objectives At the end of this lesson the student would be able to: Explain why debugging is needed.

More information

Applicative programming with effects

Applicative programming with effects Under consideration for publication in J. Functional Programming 1 F U N C T I O N A L P E A R L Applicative programming with effects CONOR MCBRIDE University of Nottingham ROSS PATERSON City University,

More information

6.090, IAP 2005 Lecture 8

6.090, IAP 2005 Lecture 8 1 MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.090 Building Programming Experience IAP 2005 Lecture 8 Tags ; professor abstraction (define (make professor

More information

Classification/Decision Trees (II)

Classification/Decision Trees (II) Classification/Decision Trees (II) Department of Statistics The Pennsylvania State University Email: jiali@stat.psu.edu Right Sized Trees Let the expected misclassification rate of a tree T be R (T ).

More information

Why Use Binary Trees?

Why Use Binary Trees? Binary Search Trees Why Use Binary Trees? Searches are an important application. What other searches have we considered? brute force search (with array or linked list) O(N) binarysearch with a pre-sorted

More information

A Seamless, Client-Centric Programming Model for Type Safe Web Applications

A Seamless, Client-Centric Programming Model for Type Safe Web Applications A Seamless, Client-Centric Programming Model for Type Safe Web Applications Anton Ekblad and Koen Claessen Chalmers University of Technology {antonek,koen}@chalmers.se Abstract We propose a new programming

More information

Special Directions for this Test

Special Directions for this Test 1 Spring, 2013 Name: (Please do not write your id number!) COP 4020 Programming Languages I Test on Haskell and Functional Programming Special Directions for this Test This test has 7 questions and pages

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

Building Queries in Microsoft Access 2007

Building Queries in Microsoft Access 2007 Building Queries in Microsoft Access 2007 Description In this class we will explore the purpose, types and uses of Queries. Learn to design a query to retrieve specific data using criteria and operators.

More information

The Happstack Book: Modern, Type-Safe Web Development in Haskell. Jeremy Shaw

The Happstack Book: Modern, Type-Safe Web Development in Haskell. Jeremy Shaw The Happstack Book: Modern, Type-Safe Web Development in Haskell Jeremy Shaw 2 Contents 1 Introduction 9 2 Hello World 11 Your first app!............................... 11 The parts of Hello World.........................

More information

Stacks. Data Structures and Data Types. Collections

Stacks. Data Structures and Data Types. Collections Data Structures and Data Types Data types Set values. Set operations on those values. Some are built in to Java: int, double, char,... Most are not: Complex, Picture, Charge, Stack, Queue, Graph,... Data

More information

Deriving a Relationship from a Single Example

Deriving a Relationship from a Single Example Deriving a Relationship from a Single Example Neil Mitchell ndmitchell@gmail.com Abstract Given an appropriate domain specific language (DSL), it is possible to describe the relationship between Haskell

More information

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing

More information

Advanced Functional Programming (9) Domain Specific Embedded Languages

Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages, Universiteit Utrecht http://www.cs.uu.nl/groups/st/ February

More information

Bevezetés a C++ Standard Template Library-be

Bevezetés a C++ Standard Template Library-be C++, 1/ 33 Bevezetés a C++ Standard Template Library-be Pataki Norbert 2013. május 17. C++, 2/ 33 STL STL vs. STL implementáció Konténerek Funktorok Algoritmusok Iterátorok STL Konténerek C++, 3/ 33 Szekvenciális:

More information

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and: Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

More information

3 Some Integer Functions

3 Some Integer Functions 3 Some Integer Functions A Pair of Fundamental Integer Functions The integer function that is the heart of this section is the modulo function. However, before getting to it, let us look at some very simple

More information

Programming Fundamentals. Lesson 20 Sections

Programming Fundamentals. Lesson 20 Sections Programming Fundamentals Lesson 20 Sections Today, we will Study sections, in Haskell. Sections are another class of expressions that represent functions. A section is a binary operation where one of the

More information

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

System.out.println(\nEnter Product Number 1-5 (0 to stop and view summary) : Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class

More information

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland Software Testing & Analysis (F22ST3) Static Analysis Techniques Andrew Ireland School of Mathematical and Computer Science Heriot-Watt University Edinburgh Software Testing & Analysis (F22ST3): Static

More information

Reactive Slick for Database Programming. Stefan Zeiger

Reactive Slick for Database Programming. Stefan Zeiger Reactive Slick for Database Programming Stefan Zeiger Introduction Slick 3.0 Reactive Slick Completely new API for executing database actions Old API (Invoker, Executor) deprecated Will be removed in 3.1

More information

Chapter 5. Recursion. Data Structures and Algorithms in Java

Chapter 5. Recursion. Data Structures and Algorithms in Java Chapter 5 Recursion Data Structures and Algorithms in Java Objectives Discuss the following topics: Recursive Definitions Method Calls and Recursion Implementation Anatomy of a Recursive Call Tail Recursion

More information

PTI891: Deklarative Programmierung

PTI891: Deklarative Programmierung PTI891: Deklarative Programmierung Web-Applikation mit Happstack Framework Lizenz: Author: Verfechter: Home page: Dokumentation: Package & repositories BSD3 Happstack team, HAppS LLC Happstack team

More information

Left-Handed Completeness

Left-Handed Completeness Left-Handed Completeness Dexter Kozen Computer Science Department Cornell University RAMiCS, September 19, 2012 Joint work with Alexandra Silva Radboud University Nijmegen and CWI Amsterdam Result A new

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach. DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER Purpose: The purpose of this tutorial is to develop a java web service using a top-down approach. Topics: This tutorial covers the following topics:

More information

Secrets of Event Viewer for Active Directory Security Auditing Lepide Software

Secrets of Event Viewer for Active Directory Security Auditing Lepide Software Secrets of Event Viewer for Active Directory Security Auditing Windows Event Viewer doesn t need any introduction to the IT Administrators. However, some of its hidden secrets, especially those related

More information

Python for Rookies. Example Examination Paper

Python for Rookies. Example Examination Paper Python for Rookies Example Examination Paper Instructions to Students: Time Allowed: 2 hours. This is Open Book Examination. All questions carry 25 marks. There are 5 questions in this exam. You should

More information

Project Planning and Scheduling

Project Planning and Scheduling Project Planning and Scheduling MFS606 Project Planning Preliminary Coordination Detailed Task Description Objectives Budgeting Scheduling Project Status Monitoring When, What, Who Project Termination

More information

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically. My Docs Online Secure File Delivery API: C# Introduction My Docs Online has provided HIPAA-compliant Secure File Sharing and Delivery since 1999. With the most recent release of its web client and Java

More information

B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion Static Hashing Extendable Hashing Questions in pass papers

B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion Static Hashing Extendable Hashing Questions in pass papers B+ Tree and Hashing B+ Tree Properties B+ Tree Searching B+ Tree Insertion B+ Tree Deletion Static Hashing Extendable Hashing Questions in pass papers B+ Tree Properties Balanced Tree Same height for paths

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

More information

A Sane Approach to Modern Web Application Development. Adam Chlipala February 22, 2010

A Sane Approach to Modern Web Application Development. Adam Chlipala February 22, 2010 A Sane Approach to Modern Web Application Development Adam Chlipala February 22, 2010 1 Web 1.0 Application Hello world! 2 Forms blah This field is called name. Page Name:

More information

Asymptotic Improvement of Computations over Free Monads

Asymptotic Improvement of Computations over Free Monads Asymptotic Improvement of Computations over Free Monads Janis Voigtländer Institut für Theoretische Informatik Technische Universität Dresden 01062 Dresden, Germany janis.voigtlaender@acm.org Abstract.

More information

Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014 German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Ahmed Gamal Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

More information

Chapter 15 Functional Programming Languages

Chapter 15 Functional Programming Languages Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,

More information

Programming in Access VBA

Programming in Access VBA PART I Programming in Access VBA In this part, you will learn all about how Visual Basic for Applications (VBA) works for Access 2010. A number of new VBA features have been incorporated into the 2010

More information

Anatomy of Programming Languages. William R. Cook

Anatomy of Programming Languages. William R. Cook Anatomy of Programming Languages William R. Cook Copyright (C) 2013 2 Chapter 1 Preliminaries Preface What? This document is a series of notes about programming languages, originally written for students

More information

DHCP and DNS Protocols

DHCP and DNS Protocols DHCP and DNS Protocols DHCP (Dynamic Host Configuration Protocol) is an industry standard protocol that lets a DHCP server (Unix/Window/As400 system) allocate temporary IP addresses and other network parameters

More information

Developing SQL and PL/SQL with JDeveloper

Developing SQL and PL/SQL with JDeveloper Seite 1 von 23 Developing SQL and PL/SQL with JDeveloper Oracle JDeveloper 10g Preview Technologies used: SQL, PL/SQL An Oracle JDeveloper Tutorial September 2003 Content This tutorial walks through the

More information

Typeset in L A TEX from SGML source using the DocBuilder-0.9.8 Document System.

Typeset in L A TEX from SGML source using the DocBuilder-0.9.8 Document System. OS Mon version 2.1 Typeset in L A TEX from SGML source using the DocBuilder-0.9.8 Document System. Contents 1 OS Mon Reference Manual 1 1.1 os mon............................................ 4 1.2 cpu

More information

Solutions to Homework 6

Solutions to Homework 6 Solutions to Homework 6 Debasish Das EECS Department, Northwestern University ddas@northwestern.edu 1 Problem 5.24 We want to find light spanning trees with certain special properties. Given is one example

More information

Binary Search Trees (BST)

Binary Search Trees (BST) Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search

More information

Functional Programming in C++11

Functional Programming in C++11 Functional Programming in C++11 science + computing ag IT-Dienstleistungen und Software für anspruchsvolle Rechnernetze Tübingen München Berlin Düsseldorf An Overview Programming in a functional style

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Loyalty Program Guide

Loyalty Program Guide Loyalty Program Guide 110911 2011 Blackbaud, Inc. This publication, or any part thereof, may not be reproduced or transmitted in any form or by any means, electronic, or mechanical, including photocopying,

More information

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive. Recursion Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive. Why recursion? o For many problems, the recursion solution is more natural than the alternative

More information

BIRCH: An Efficient Data Clustering Method For Very Large Databases

BIRCH: An Efficient Data Clustering Method For Very Large Databases BIRCH: An Efficient Data Clustering Method For Very Large Databases Tian Zhang, Raghu Ramakrishnan, Miron Livny CPSC 504 Presenter: Discussion Leader: Sophia (Xueyao) Liang HelenJr, Birches. Online Image.

More information

Basics of I/O Streams and File I/O

Basics of I/O Streams and File I/O Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

More information

Practical Generic Programming with OCaml

Practical Generic Programming with OCaml Practical Generic Programming with OCaml Jeremy Yallop LFCS, University of Edinburgh ML Workshop 2007 Instead of this... type α tree = Node of α Branch of (α tree) (α tree) val show_tree : (α string) (α

More information

CS 245 Final Exam Winter 2013

CS 245 Final Exam Winter 2013 CS 245 Final Exam Winter 2013 This exam is open book and notes. You can use a calculator and your laptop to access course notes and videos (but not to communicate with other people). You have 140 minutes

More information

GeoVision Setup. Once all the settings for Windows are completed and you have all the hard drives setup you can install GeoVision.

GeoVision Setup. Once all the settings for Windows are completed and you have all the hard drives setup you can install GeoVision. GeoVision Setup Once all the settings for Windows are completed and you have all the hard drives setup you can install GeoVision. Start in order beginning with the drivers. When you install the drivers

More information

Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test

Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test 1 Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test Definition: Prime numbers are numbers with only two factors, one and itself. For example: 2, 3, and 5. Definition: Composite numbers

More information

Chapter 2. Making Shapes

Chapter 2. Making Shapes Chapter 2. Making Shapes Let's play turtle! You can use your Pencil Turtle, you can use yourself, or you can use some of your friends. In fact, why not try all three? Rabbit Trail 4. Body Geometry Can

More information

Factoring. Factoring Monomials Monomials can often be factored in more than one way.

Factoring. Factoring Monomials Monomials can often be factored in more than one way. Factoring Factoring is the reverse of multiplying. When we multiplied monomials or polynomials together, we got a new monomial or a string of monomials that were added (or subtracted) together. For example,

More information

1998. (R. Bird and P. Wadler, Introduction to Functional Programming, Prentice

1998. (R. Bird and P. Wadler, Introduction to Functional Programming, Prentice Mathematical Structures in Programs 15 Algebra) The Shorter Oxford English Dictionary): the reunion of broken parts a calculus of symbols combined according to defined laws Haskell 3 4 Richard Bird. Introduction

More information

Using Microsoft Dynamics AX 2012

Using Microsoft Dynamics AX 2012 Exercise Guide Andreas Luszczak Using Microsoft Dynamics AX 2012 Springer Vieweg, 2nd Edition 2012 ISBN 978-3-8348-1742-6 September 2012 VI Exercise Guide Registered and/or industrial names, trade names,

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

More information

HP LeftHand SAN Solutions

HP LeftHand SAN Solutions HP LeftHand SAN Solutions Support Document Applications Notes Best Practices for Using SolarWinds' ORION to Monitor SANiQ Performance Legal Notices Warranty The only warranties for HP products and services

More information

How to Setup SQL Server Replication

How to Setup SQL Server Replication Introduction This document describes a scenario how to setup the Transactional SQL Server Replication. Before we proceed for Replication setup you can read brief note about Understanding of Replication

More information

Report on the Train Ticketing System

Report on the Train Ticketing System Report on the Train Ticketing System Author: Zaobo He, Bing Jiang, Zhuojun Duan 1.Introduction... 2 1.1 Intentions... 2 1.2 Background... 2 2. Overview of the Tasks... 3 2.1 Modules of the system... 3

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

This is a training module for Maximo Asset Management V7.1. In this module, you learn to use the E-Signature user authentication feature.

This is a training module for Maximo Asset Management V7.1. In this module, you learn to use the E-Signature user authentication feature. This is a training module for Maximo Asset Management V7.1. In this module, you learn to use the E-Signature user authentication feature. Page 1 of 16 When you complete this module, you can perform these

More information

The Leader Election Protocol of IEEE 1394 in Maude

The Leader Election Protocol of IEEE 1394 in Maude The Leader Election Protocol of IEEE 1394 in Maude Alberto Verdejo, Isabel Pita, and Narciso Martí-Oliet Technical Report 118.01 Dpto. de Sistemas Informáticos y Programación Universidad Complutense de

More information

CSc 372. Comparative Programming Languages. 21 : Haskell Accumulative Recursion. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 21 : Haskell Accumulative Recursion. Department of Computer Science University of Arizona 1/18 CSc 372 Comparative Programming Languages 21 : Haskell Accumulative Recursion Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/18 Stack

More information

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions

More information

Programming in IDRIS: A Tutorial

Programming in IDRIS: A Tutorial Programming in IDRIS: A Tutorial The IDRIS Community 15th January 2015 Contents 1 Introduction 3 1.1 Intended Audience......................................... 3 1.2 Example Code............................................

More information

HSL and its out-of-core solver

HSL and its out-of-core solver HSL and its out-of-core solver Jennifer A. Scott j.a.scott@rl.ac.uk Prague November 2006 p. 1/37 Sparse systems Problem: we wish to solve where A is Ax = b LARGE Informal definition: A is sparse if many

More information

Class Notes CS 3137. 1 Creating and Using a Huffman Code. Ref: Weiss, page 433

Class Notes CS 3137. 1 Creating and Using a Huffman Code. Ref: Weiss, page 433 Class Notes CS 3137 1 Creating and Using a Huffman Code. Ref: Weiss, page 433 1. FIXED LENGTH CODES: Codes are used to transmit characters over data links. You are probably aware of the ASCII code, a fixed-length

More information

The Technology Behind a Graphical User Interface for an Equational Reasoning Assistant

The Technology Behind a Graphical User Interface for an Equational Reasoning Assistant The Technology Behind a Graphical User Interface for an Equational Reasoning Assistant Andy Gill Department of Computing Science, University of Glasgow Abstract The Haskell Equational Reasoning Assistant

More information

MACM 101 Discrete Mathematics I

MACM 101 Discrete Mathematics I MACM 101 Discrete Mathematics I Exercises on Combinatorics, Probability, Languages and Integers. Due: Tuesday, November 2th (at the beginning of the class) Reminder: the work you submit must be your own.

More information

Computer Science at Kent

Computer Science at Kent Computer Science at Kent Transformation in HaRe Chau Nguyen-Viet Technical Report No. 21-04 December 2004 Copyright 2004 University of Kent Published by the Computing Laboratory, University of Kent, Canterbury,

More information

IVR Studio 3.0 Guide. May-2013. Knowlarity Product Team

IVR Studio 3.0 Guide. May-2013. Knowlarity Product Team IVR Studio 3.0 Guide May-2013 Knowlarity Product Team Contents IVR Studio... 4 Workstation... 4 Name & field of IVR... 4 Set CDR maintainence property... 4 Set IVR view... 4 Object properties view... 4

More information

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters

More information

Full and Complete Binary Trees

Full and Complete Binary Trees Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

More information

monadws: A Monad-Based Testing Tool for Web Services

monadws: A Monad-Based Testing Tool for Web Services monadws: A Monad-Based Testing Tool for Web Services College of Computer, Nanjing University of Posts and Telecommunications, Nanjing 210003, China Yingzhou Zhang, Wei Fu, Changhai Nie Email: zhangyz@njupt.edu.cn

More information

Using Xilinx ISE for VHDL Based Design

Using Xilinx ISE for VHDL Based Design ECE 561 Project 4-1 - Using Xilinx ISE for VHDL Based Design In this project you will learn to create a design module from VHDL code. With Xilinx ISE, you can easily create modules from VHDL code using

More information

Exporting Email Addresses. for Use in Outlook Express

Exporting Email Addresses. for Use in Outlook Express Exporting Email Addresses for Use in Outlook Express If your Keystroke Customer database includes email addresses, it is a relatively simple and easy process to export the Customer records and import them

More information