1 / 11

Programming Paradigms

Programming Paradigms. CPSC 449 Week 5 Prepared by : Mona Hosseinkhani , Arash Afshar Winter 2014. Department of Computer Science, University of Calgary. Understanding definitions. Alternatives Evaluate on particular inputs Using an implementation (e.g. GHCi )

waylon
Download Presentation

Programming Paradigms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Paradigms CPSC 449 Week 5 Prepared by : Mona Hosseinkhani, ArashAfshar Winter 2014 Department of Computer Science, University of Calgary

  2. Understanding definitions • Alternatives • Evaluate on particular inputs • Using an implementation (e.g. GHCi) • By hand (by performing a line by line calculation) • Argue about how it behaves in general • Example

  3. Evaluation on particular inputs

  4. Analyze the behavior in general • Find general properties of length • length [x] = 1 • length (xs ++ ys) = length xs + length ys • We could show • This is called Symbolic Evaluation. • Rather than evaluating length at a particular value, we used a variable x. So for all values of x:

  5. Understanding definitions • Symbolic evaluation is an important part of the proofs. • But we also need another principle: induction to do most proofs for recursive functions • Note that understanding and describing definitions in imperative languages (e.g. Pascal) is very difficult

  6. Program correctness: recall • Test on inputs • Property-based test • Proof

  7. Total correctness (proof)

  8. Example • No termination

  9. Lazy evaluation • Evaluate • Haskell evaluates an expression only if its value is actually needed.

  10. Questions hossem@ucalgary.ca

  11. Install bmp package for next assignment • http://hackage.haskell.org/package/bmp • $ cabal update • $ cabal install cabal-install • if the last step is successful execute the following • $ cabal install bmp

More Related