CS计算机代考程序代写 prolog Java c++ Haskell assembly “Learn at least a half dozen programming languages. Include one language that emphasizes class abstractions (like Java or C++), one that emphasizes functional ab- straction (like Lisp or ML or Haskell), one that supports syntactic abstraction (like Lisp), one that supports declar- ative specifications (like Prolog or C++ templates), and one that emphasizes parallelism (like Clojure or Go).”

“Learn at least a half dozen programming languages. Include one language that emphasizes class abstractions (like Java or C++), one that emphasizes functional ab- straction (like Lisp or ML or Haskell), one that supports syntactic abstraction (like Lisp), one that supports declar- ative specifications (like Prolog or C++ templates), and one that emphasizes parallelism (like Clojure or Go).”
Peter Norvig “Teach Yourself Programming in Ten Years”
http://norvig.com/21-days.html
©D. Poole 2021
CPSC 312 — Lecture 1 1/8

CPSC 312 — Functional and Logic Programming
Professor: David Poole
URL: http://www.cs.ubc.ca/~poole/cs312/2021/ Assignment 1 is due next Tuesday!
There is a textbook for first half (functional programming). We will use Canvas for assignment submission, grades and Zooming. Classes will be recorded an available on Canvas. (Remind me to record).
Pre-class videos (on Schedule tab) will contain the course content. Classes are for examples, questions, and interaction. Every student should expect to struggle, but can succeed! You learn by doing and making mistakes.
Ask questions!
Quote of the day: “Apparently, the university is the only place where you pay for something, and then try as hard as you can NOT to get your money’s worth.” (https://people.cs.kuleuven.be/~bart.demoen/)
CPSC 312 — Lecture 1 2/8
©D. Poole 2021

CPSC 312 — Assessment
Marks:
􏰌 40%: 2 projects (groups 2 or 3) with demos
􏰌 30%: 3 midterms (10% each). Tentative dates on web page
(subject to change).
􏰌 25%: final exam
􏰌 3%: assignments (marked for participation)
􏰌 2% informative discussion posts.
Estimates:
Everyone can pass
If you memorize and can reproduce everything presented in class you can get a B- or C+.
For an A or A+ you have to “get it” (“aha!” moment).
CPSC 312 — Lecture 1 3/8
©D. Poole 2021

Lecture Overview
What is logic and functional programming?
Simple Haskell programs and queries.
Learning objectives: at the end of the class, you should be able to
recognize components of a functional program write a simple Haskell program
CPSC 312 — Lecture 1 4/8
©D. Poole 2021

What is functional and logic programming?
Program is a high-level specification of what should be computed, not how it should be computed.
Try to find representations that are as close to the problem domain as possible
Abstract away from the state of a computer
Programming and debugging should all be questions about the domain, not about the computation.
Allow computer to decide how to most efficiently implement the program.
To solve a complex problem, break it into simpler problems. Variables cannot change their values. Controlled side effects.
Haskell is a strongly typed language. You don’t need to declare types. Type checking is done at compile time.
CPSC 312 — Lecture 1 5/8
©D. Poole 2021

Choosing a Representation Language
We need to represent a problem to solve it on a computer.
 problem   → specification of problem 
→ appropriate computation
Example representation languages: Machine Language, C++, Java, Haskell, Prolog, English
©D. Poole 2021
CPSC 312 — Lecture 1 6/8

Hierarchy of representations
problem solution high-level specification
programming language assembly language
digital circuit currents and voltages
©D. Poole 2021
CPSC 312 — Lecture 1 7/8

Haskell
http://cs.ubc.ca/~poole/cs312/2021/haskell/First.pl
©D. Poole 2021
CPSC 312 — Lecture 1 8/8