1
Shell CSCE 314 TAMU
Haskell Functions
CSCE 314: Programming Languages
- Dr. Dylan Shell
Haskell Functions 1 Shell CSCE 314 TAMU Outline Defining - - PowerPoint PPT Presentation
Shell CSCE 314 TAMU CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 1 Shell CSCE 314 TAMU Outline Defining Functions List Comprehensions Recursion 2 Shell CSCE 314 TAMU Conditional Expressions As in most
1
Shell CSCE 314 TAMU
2
Shell CSCE 314 TAMU
3
Shell CSCE 314 TAMU
As in most programming languages, functions can be defined using conditional expressions: if cond then e1 else e2
4
Shell CSCE 314 TAMU
Prelude:
5
Shell CSCE 314 TAMU
6
Shell CSCE 314 TAMU
7
Shell CSCE 314 TAMU
→ →
8
Shell CSCE 314 TAMU
9
Shell CSCE 314 TAMU
→ → head and tail map any non-empty list to its first and remaining elements. is this definition complete?
10
Shell CSCE 314 TAMU
11
Shell CSCE 314 TAMU
12
Shell CSCE 314 TAMU
λ →
backslash \.
x ↦ x+x.
calculus, the theory of functions on which Haskell is based.
13
Shell CSCE 314 TAMU
14
Shell CSCE 314 TAMU
15
Shell CSCE 314 TAMU
(1) (2)
16
Shell CSCE 314 TAMU
(1) (2)
17
Shell CSCE 314 TAMU
18
Shell CSCE 314 TAMU
19
Shell CSCE 314 TAMU
20
Shell CSCE 314 TAMU
21
Shell CSCE 314 TAMU
22
Shell CSCE 314 TAMU
23
Shell CSCE 314 TAMU
24
Shell CSCE 314 TAMU
25
Shell CSCE 314 TAMU
26
Shell CSCE 314 TAMU
27
Shell CSCE 314 TAMU
28
Shell CSCE 314 TAMU
29
Shell CSCE 314 TAMU
30
Shell CSCE 314 TAMU
≤
31
Shell CSCE 314 TAMU
32
Shell CSCE 314 TAMU
→
33
Shell CSCE 314 TAMU
i = 0 n-1