Download presentation

Presentation is loading. Please wait.

Published byEric Page Modified over 4 years ago

1
CS4026 Formal Models of Computation Running Haskell Programs – power

2
formal models of computation 2 How functional programs work… We have seen simple programs such as Lets now see how they are executed Given the program above, we get the following: But how? power x 0 = 1 power x (n+1) = x * (power x n) power 2 3 8

3
formal models of computation 3 How functional programs work… Execution: power 2 3 power x 0 = 1 power x (n+1) = x * (power x n)

4
formal models of computation 4 How functional programs work… Execution: power 2 3 power x 0 = 1 power x (n+1) = x * (power x n) 3 matches (n+1), assigning 2 to n

5
formal models of computation 5 How functional programs work… Execution: power 2 3 2 * (power 2 2) power x 0 = 1 power x (n+1) = x * (power x n)

6
formal models of computation 6 How functional programs work… Execution: power 2 3 2 * (power 2 2) power x 0 = 1 power x (n+1) = x * (power x n)

7
formal models of computation 7 How functional programs work… Execution: power 2 3 2 * (power 2 2) power x 0 = 1 power x (n+1) = x * (power x n) 2 matches (n+1), assigning 1 to n

8
formal models of computation 8 How functional programs work… Execution: power 2 3 2 * (2 * (power 2 1)) power x 0 = 1 power x (n+1) = x * (power x n)

9
formal models of computation 9 How functional programs work… Execution: power 2 3 2 * (2 * (power 2 1)) power x 0 = 1 power x (n+1) = x * (power x n)

10
formal models of computation 10 How functional programs work… Execution: power 2 3 2 * (2 * (power 2 1)) power x 0 = 1 power x (n+1) = x * (power x n) 1 matches (n+1), assigning 0 to n

11
formal models of computation 11 How functional programs work… Execution: power 2 3 2 * (2 * (2 * (power 2 0))) power x 0 = 1 power x (n+1) = x * (power x n)

12
formal models of computation 12 How functional programs work… Execution: power 2 3 2 * (2 * (2 * (power 2 0))) power x 0 = 1 power x (n+1) = x * (power x n)

13
formal models of computation 13 How functional programs work… Execution: power 2 3 2 * (2 * (2 * (power 2 0))) power x 0 = 1 power x (n+1) = x * (power x n)

14
formal models of computation 14 How functional programs work… Execution: power 2 3 2 * (2 * (2 * (1))) power x 0 = 1 power x (n+1) = x * (power x n)

15
formal models of computation 15 How functional programs work… Execution: power 2 3 8 power x 0 = 1 power x (n+1) = x * (power x n)

Similar presentations

OK

Lets play bingo!!. Calculate: MEAN 4 7 5 8 6 Calculate: MEDIAN 9 4 6 1 5.

Lets play bingo!!. Calculate: MEAN 4 7 5 8 6 Calculate: MEDIAN 9 4 6 1 5.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on polynomials in maths what is the range Ppt on column chromatography uses Ppt on combination of resistances series File type ppt on cybercrime virus Ppt on area of parallelogram vectors Ppt on introduction to object-oriented programming advantages Ppt on indian army weapons pictures Ppt on tsunami in 2004 Business intelligence microsoft ppt online Ppt on northern rivers of india