-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.html
763 lines (607 loc) · 24.7 KB
/
presentation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Functional Programming and the Lambda Calculus</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<meta name="title" content="Functional Programming and the Lambda Calculus"/>
<meta name="generator" content="Org-mode"/>
<meta name="generated" content="2013-05-13 17:09:27 Eastern Daylight Time"/>
<meta name="author" content="Ed Cole"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color: #add8e6; font-weight:normal }
.target { }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.right {margin-left:auto; margin-right:0px; text-align:right;}
.left {margin-left:0px; margin-right:auto; text-align:left;}
.center {margin-left:auto; margin-right:auto; text-align:center;}
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: courier, monospace;
font-size: 90%;
overflow:auto;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
th.right { text-align:center; }
th.left { text-align:center; }
th.center { text-align:center; }
td.right { text-align:right; }
td.left { text-align:left; }
td.center { text-align:center; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
div.inlinetask {
padding:10px;
border:2px solid gray;
margin:10px;
background: #ffffcc;
}
textarea { overflow-x: auto; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="css/presentation.css" />
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="preamble">
</div>
<div id="content">
<h1 class="title">Functional Programming and the Lambda Calculus</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Overview</a>
<ul>
<li><a href="#sec-1-1">1.1 The relationship between computer programming and mathematics.</a>
<ul>
<li><a href="#sec-1-1-1">1.1.1 Variables and functions</a></li>
<li><a href="#sec-1-1-2">1.1.2 What is a function?</a></li>
</ul>
</li>
<li><a href="#sec-1-2">1.2 Functions</a>
<ul>
<li><a href="#sec-1-2-1">1.2.1 First-class objects</a></li>
<li><a href="#sec-1-2-2">1.2.2 No side effects</a></li>
<li><a href="#sec-1-2-3">1.2.3 Immutability</a></li>
</ul></li>
</ul>
</li>
<li><a href="#sec-2">2 The Lambda Calculus</a>
<ul>
<li><a href="#sec-2-1">2.1 Examples</a>
<ul>
<li><a href="#sec-2-1-1">2.1.1 Example 1 – Identity</a></li>
<li><a href="#sec-2-1-2">2.1.2 Example 2 – Self-apply</a></li>
<li><a href="#sec-2-1-3">2.1.3 Example 3 – Boolean true and false</a></li>
<li><a href="#sec-2-1-4">2.1.4 Example 4 – if-then-else</a></li>
</ul>
</li>
<li><a href="#sec-2-2">2.2 Abbreviated Form</a></li>
<li><a href="#sec-2-3">2.3 Optimization</a></li>
</ul>
</li>
<li><a href="#sec-3">3 Functional Programming Languages</a>
<ul>
<li><a href="#sec-3-1">3.1 Lisp</a>
<ul>
<li><a href="#sec-3-1-1">3.1.1 Emacs Lisp</a></li>
<li><a href="#sec-3-1-2">3.1.2 Scheme</a></li>
<li><a href="#sec-3-1-3">3.1.3 Clojure</a></li>
</ul>
</li>
<li><a href="#sec-3-2">3.2 JavaScript</a></li>
<li><a href="#sec-3-3">3.3 Groovy</a></li>
<li><a href="#sec-3-4">3.4 Haskell</a></li>
<li><a href="#sec-3-5">3.5 Scala</a></li>
</ul>
</li>
<li><a href="#sec-4">4 Functions as First-Class Objects</a>
<ul>
<li><a href="#sec-4-1">4.1 Callbacks</a></li>
<li><a href="#sec-4-2">4.2 Asynchronous operations</a></li>
<li><a href="#sec-4-3">4.3 Hooks</a></li>
<li><a href="#sec-4-4">4.4 State tables</a></li>
</ul>
</li>
<li><a href="#sec-5">5 Closures</a></li>
<li><a href="#sec-6">6 Combinators</a></li>
<li><a href="#sec-7">7 Recursion</a></li>
<li><a href="#sec-8">8 Lists</a></li>
<li><a href="#sec-9">9 Javascript</a></li>
<li><a href="#sec-10">10 Groovy</a></li>
<li><a href="#sec-11">11 Monads</a>
<ul>
<li><a href="#sec-11-1">11.1 IO monad</a></li>
<li><a href="#sec-11-2">11.2 Maybe monad</a></li>
<li><a href="#sec-11-3">11.3 Promises</a></li>
</ul>
</li>
<li><a href="#sec-12">12 Notes</a></li>
</ul>
</div>
</div>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Overview</h2>
<div class="outline-text-2" id="text-1">
<p>What is functional programming? Why does it matter?
<a href="http://en.wikipedia.org/wiki/Functional_programming">Wikipedia</a> defines functional programming as "a programming paradigm that
treats computation as the evaluation of mathematical functions and avoids
state and mutable data." This paradigm attempts to make the functions of computer science behave like the functions of mathematics.
</p>
</div>
<div id="outline-container-1-1" class="outline-3">
<h3 id="sec-1-1"><span class="section-number-3">1.1</span> The relationship between computer programming and mathematics.</h3>
<div class="outline-text-3" id="text-1-1">
</div>
<div id="outline-container-1-1-1" class="outline-4">
<h4 id="sec-1-1-1"><span class="section-number-4">1.1.1</span> Variables and functions</h4>
<div class="outline-text-4" id="text-1-1-1">
<p>Variables and functions behave differently in mathematics and most computer languages. Consider the expression x = x + 1. It is a contradiction in mathematics, but in many languages, it means to take the value that was in a location named "x" and replace it with the same value plus one.
</p></div>
</div>
<div id="outline-container-1-1-2" class="outline-4">
<h4 id="sec-1-1-2"><span class="section-number-4">1.1.2</span> What is a function?</h4>
<div class="outline-text-4" id="text-1-1-2">
<ul>
<li>In mathematics, a function is a mapping from one set (the domain) to another set (the range) in such a way that any element of the domain is mapped to exactly one element of the range.
</li>
<li>In computers, a function is a subroutine that returns a value.
</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-1-2" class="outline-3">
<h3 id="sec-1-2"><span class="section-number-3">1.2</span> Functions</h3>
<div class="outline-text-3" id="text-1-2">
</div>
<div id="outline-container-1-2-1" class="outline-4">
<h4 id="sec-1-2-1"><span class="section-number-4">1.2.1</span> First-class objects</h4>
<div class="outline-text-4" id="text-1-2-1">
<p>Functions can be assigned to variables, passed as parameters to functions, returned from functions, and created on the fly.
</p></div>
</div>
<div id="outline-container-1-2-2" class="outline-4">
<h4 id="sec-1-2-2"><span class="section-number-4">1.2.2</span> No side effects</h4>
<div class="outline-text-4" id="text-1-2-2">
<p>If the only way a function changes its environment is through its return value, it is said to have no side effects. This is essential to the Lambda Calculus.
</p></div>
</div>
<div id="outline-container-1-2-3" class="outline-4">
<h4 id="sec-1-2-3"><span class="section-number-4">1.2.3</span> Immutability</h4>
<div class="outline-text-4" id="text-1-2-3">
<p>Once a variable is set, it can never be changed.
</p></div>
</div>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> The Lambda Calculus</h2>
<div class="outline-text-2" id="text-2">
<p>The Lambda Calculus is a mathematical theory of computation that is equivalent
to Turing's model for computable functions. It is based on the manipulation of
<i>lambda expressions</i>, which are formally defined as a combination of the
following things (where A, B, and C are arbitrary λ-expressions):
</p>
<p>
<i>name</i> or λ <i>name</i> . A or (λ x.B C)
</p>
<p>
The <i>name</i> represents a unary function (i.e. a function with one argument) that
has no side effects.
</p>
<p>
The second form is called abstraction; λ x.A binds all occurences of x
in the (arbitrary) lambda expression A; It is equivalent to using x as the
parameter of a function in a modern computer language.
</p>
<p>
The third form is application of λ-expression 1 to λ-expression 2;
(λ x.B C) has the effect of replacing all occurences of x in B with C.
</p>
</div>
<div id="outline-container-2-1" class="outline-3">
<h3 id="sec-2-1"><span class="section-number-3">2.1</span> Examples</h3>
<div class="outline-text-3" id="text-2-1">
</div>
<div id="outline-container-2-1-1" class="outline-4">
<h4 id="sec-2-1-1"><span class="section-number-4">2.1.1</span> Example 1 – Identity</h4>
<div class="outline-text-4" id="text-2-1-1">
<p>λ x.x
</p>
<p>
This is the identity operation; in Groovy, it would be `{ x -> x }`.
</p></div>
</div>
<div id="outline-container-2-1-2" class="outline-4">
<h4 id="sec-2-1-2"><span class="section-number-4">2.1.2</span> Example 2 – Self-apply</h4>
<div class="outline-text-4" id="text-2-1-2">
<p>λ s.(s s)
</p>
<p>
Applies `s` to itself. In Groovy `{ s -> s(s) }`
</p>
</div>
</div>
<div id="outline-container-2-1-3" class="outline-4">
<h4 id="sec-2-1-3"><span class="section-number-4">2.1.3</span> Example 3 – Boolean true and false</h4>
<div class="outline-text-4" id="text-2-1-3">
<p>λ first.λ second.first
</p>
<p>
This takes two arguments and returns the first. ` {first, second -> first}`. It is significant because Church used it as `true` in deriving boolean logic from the λ-calculus.
</p>
<p>
λ first.λ second.second
</p>
<p>
Return the second argument. This is `false` in boolean logic.
</p>
</div>
</div>
<div id="outline-container-2-1-4" class="outline-4">
<h4 id="sec-2-1-4"><span class="section-number-4">2.1.4</span> Example 4 – if-then-else</h4>
<div class="outline-text-4" id="text-2-1-4">
<p>λ iftrue.λ iffalse.λ test.((test iftrue) iffalse)
</p>
<p>
If you apply this to a λ-expression
that evaluates to `true` or `false`, it becomes the standard if-then-else construct you find in
almost every programming language. In this case, the test is the third argument so you can curry it with iftrue and
iffalse expressions. Thus
</p>
<p>
((λ iftrue.λ iffalse.λ test.((test iftrue) iffalse) x) y) =>
(λ iffalse.λ test.((test x) iffalse) y) =>
λ test.((test x) y)
</p>
<p>
The result is a function that you apply to a boolean condition.
</p>
<p>
λ test.((test x) y) true => x
</p>
<p>
λ test.((test x) y) false => y
</p>
</div>
</div>
</div>
<div id="outline-container-2-2" class="outline-3">
<h3 id="sec-2-2"><span class="section-number-3">2.2</span> Abbreviated Form</h3>
<div class="outline-text-3" id="text-2-2">
<p>Because the lambda notation of all but the simplest expressions becomes
difficult to read because of all the parentheses, is often abbreviated
by combining the application of multiple arguments of an expression into a
single set of parentheses. Thus
</p>
<p>
λ a.λ b.λ c.(((f a) b) c)
</p>
<p>
becomes
</p>
<p>
λ a.λ b.λ c.(f a b c)
</p>
<p>
So the if-then-else example above would look like this.
</p>
<p>
λ test.λ iftrue.λ.iffalse.(test iftrue iffalse)
</p>
<p>
At this point it seems to start looking like LISP code. This is not a coincidence.
</p></div>
</div>
<div id="outline-container-2-3" class="outline-3">
<h3 id="sec-2-3"><span class="section-number-3">2.3</span> Optimization</h3>
<div class="outline-text-3" id="text-2-3">
<p>Modern computer systems, like the leading Java Virtual Machines or the V8 Javascript engine (used in Chrome and Node.js) rewrite your program as it runs to make it more efficient or to run parts of the code in parallel. The lambda calculus is helpful in analyzing the code.
</p><ul>
<li>AMD64, Itanium and parallelism
</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Functional Programming Languages</h2>
<div class="outline-text-2" id="text-3">
<p>Functional programming languages are languages in which you
can use functions as first-class objects. That means that you can assign a
function to a variable, pass it as a parameter, and perform certain operations
on it. Some languages, like Haskell are strict in enforcing the restrictions
of pure functional programming, and some are much less so.
</p>
</div>
<div id="outline-container-3-1" class="outline-3">
<h3 id="sec-3-1"><span class="section-number-3">3.1</span> Lisp</h3>
<div class="outline-text-3" id="text-3-1">
<p>Lisp is an ancient and ever new language that pioneered many of the things
we take for granted in modern programming languages. It grew out of the
Lambda Calculus, so it has had functional programming features from the
beginning.
</p>
</div>
<div id="outline-container-3-1-1" class="outline-4">
<h4 id="sec-3-1-1"><span class="section-number-4">3.1.1</span> Emacs Lisp</h4>
<div class="outline-text-4" id="text-3-1-1">
<p>In Emacs and Common Lisp, you define an anonymous function with the lambda keyword.
</p>
<pre class="example"><span class="linenr"> 1: </span>;; setq defines a local variable and assigns it a value.
<span class="linenr"> 2: </span>(setq x 1)
<span class="linenr"> 3: </span>
<span class="linenr"> 4: </span>;; x is now a variable containing the value 1
<span class="linenr"> 5: </span>(setq plus1 (lambda (a) "Add 1 to a" (+ a 1)))
<span class="linenr"> 6: </span>
<span class="linenr"> 7: </span>;; plus1 is now a variable containing an anonymous function
<span class="linenr"> 8: </span>;; that adds 1 to its single argument
<span class="linenr"> 9: </span>;;
<span class="linenr">10: </span>
<span class="linenr">11: </span>;; Invoke plus1 with argment 1
<span class="linenr">12: </span>(funcall plus1 1)
<span class="linenr">13: </span>
<span class="linenr">14: </span>;; The result is 2.
<span class="linenr">15: </span>
<span class="linenr">16: </span>;; Note that in Emacs Lisp you cannot just say (plus1 1).
</pre>
<p>
See the emacs lisp documentation on <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/Lambda-Expressions.html#Lambda-Expressions">lambdas</a> and <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding.html#Lexical-Binding">closures</a>.
There are Many flavors of Lisp, but I think the most
important ones are listed below.
</p></div>
</div>
<div id="outline-container-3-1-2" class="outline-4">
<h4 id="sec-3-1-2"><span class="section-number-4">3.1.2</span> Scheme</h4>
<div class="outline-text-4" id="text-3-1-2">
<p>You don't have to use the funcall function in Scheme; you would
just invoke it like any other function.
(See <a href="ftp://ftp.cs.utexas.edu/pub/garbage/cs345/schintro-v14/schintro_122.html">An Introduction to Scheme and its Implementation</a>)
</p>
<pre class="example"><span class="linenr"> 1: </span>(define x 1)
<span class="linenr"> 2: </span>(print "x is now a variable containing the value 1")
<span class="linenr"> 3: </span>(print x)
<span class="linenr"> 4: </span>;; Define, but do not assign, plus1
<span class="linenr"> 5: </span>(define plus1)
<span class="linenr"> 6: </span>(set! plus1 (lambda (a) "Add 1 to a" (+ a 1)))
<span class="linenr"> 7: </span>(print "plus1 is now a variable containing an anonymous function")
<span class="linenr"> 8: </span>(print " that adds 1 to its single argument")
<span class="linenr"> 9: </span>(print "")
<span class="linenr">10: </span>(print "Invoke plus1 with argument x")
<span class="linenr">11: </span>(print (plus1 x))(define x 1)
<span class="linenr">12: </span>(print "x is now a variable containing the value 1")
<span class="linenr">13: </span>(print x)
<span class="linenr">14: </span>;; Define, but do not assign, plus1
<span class="linenr">15: </span>(define plus1)
<span class="linenr">16: </span>(set! plus1 (lambda (a) "Add 1 to a" (+ a 1)))
<span class="linenr">17: </span>(print "plus1 is now a variable containing an anonymous function")
<span class="linenr">18: </span>(print " that adds 1 to its single argument")
<span class="linenr">19: </span>(print "")
<span class="linenr">20: </span>(print "Invoke plus1 with argument x")
<span class="linenr">21: </span>(print (plus1 x))
</pre>
<p>
This is evaluated by the Scheme interpreter at <a href="http://repl.it">repl.it</a>
</p>
<pre class="example">x is now a variable containing the value 1
1
plus1 is now a variable containing an anonymous function
that adds 1 to its single argument
Invoke plus1 with argument x
2
</pre>
</div>
</div>
<div id="outline-container-3-1-3" class="outline-4">
<h4 id="sec-3-1-3"><span class="section-number-4">3.1.3</span> Clojure</h4>
<div class="outline-text-4" id="text-3-1-3">
<p>Clojure is a Lisp implementation for the Java Virtual Machine, but it has a
focus on concurrency.
</p>
<pre class="example">(def x 1)
(def plus1)
(def plus1 (fn [a] (+ a 1)))
(plus1 1)
</pre>
<p>
<a href="http://tryclj.com/">http://tryclj.com/</a>
</p></div>
</div>
</div>
<div id="outline-container-3-2" class="outline-3">
<h3 id="sec-3-2"><span class="section-number-3">3.2</span> JavaScript</h3>
<div class="outline-text-3" id="text-3-2">
<p>JavaScript is the first mainstream language with closures. It is also a
language that we can't escape working with.
</p>
<pre class="example"><span class="linenr"> 1: </span>// Define the variables
<span class="linenr"> 2: </span>var x = 1, plus1;
<span class="linenr"> 3: </span>
<span class="linenr"> 4: </span>plus1 = function (a) {
<span class="linenr"> 5: </span> return a + 1;
<span class="linenr"> 6: </span>}
<span class="linenr"> 7: </span>
<span class="linenr"> 8: </span>// plus1 is now a variable containing an anonymous function
<span class="linenr"> 9: </span>// that adds 1 to its single argument
<span class="linenr">10: </span>//
<span class="linenr">11: </span>
<span class="linenr">12: </span>// Invoke plus1 with argment 1
<span class="linenr">13: </span>plus1(1);
</pre>
</div>
</div>
<div id="outline-container-3-3" class="outline-3">
<h3 id="sec-3-3"><span class="section-number-3">3.3</span> Groovy</h3>
<div class="outline-text-3" id="text-3-3">
<pre class="example"><span class="linenr">1: </span>def x = 1
<span class="linenr">2: </span>def plus1 = { a -> a + 1 }
<span class="linenr">3: </span>plus1(x)
</pre>
</div>
</div>
<div id="outline-container-3-4" class="outline-3">
<h3 id="sec-3-4"><span class="section-number-3">3.4</span> Haskell</h3>
<div class="outline-text-3" id="text-3-4">
<p>Haskell is a strictly functional programming language. This introduces disadvantages as well as advantages, but it was originally an academic language
</p></div>
</div>
<div id="outline-container-3-5" class="outline-3">
<h3 id="sec-3-5"><span class="section-number-3">3.5</span> Scala</h3>
<div class="outline-text-3" id="text-3-5">
<p>Scala is another language designed for the JVM, which introduces some functional concepts.
</p>
<pre class="example">var plus1 = (x: Int) => x + 1
plus1(1)
</pre>
</div>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Functions as First-Class Objects</h2>
<div class="outline-text-2" id="text-4">
<p> Callbacks, Hooks, and Ajax
</p>
</div>
<div id="outline-container-4-1" class="outline-3">
<h3 id="sec-4-1"><span class="section-number-3">4.1</span> Callbacks</h3>
<div class="outline-text-3" id="text-4-1">
</div>
</div>
<div id="outline-container-4-2" class="outline-3">
<h3 id="sec-4-2"><span class="section-number-3">4.2</span> Asynchronous operations</h3>
<div class="outline-text-3" id="text-4-2">
</div>
</div>
<div id="outline-container-4-3" class="outline-3">
<h3 id="sec-4-3"><span class="section-number-3">4.3</span> Hooks</h3>
<div class="outline-text-3" id="text-4-3">
</div>
</div>
<div id="outline-container-4-4" class="outline-3">
<h3 id="sec-4-4"><span class="section-number-3">4.4</span> State tables</h3>
<div class="outline-text-3" id="text-4-4">
</div>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Closures</h2>
<div class="outline-text-2" id="text-5">
<p>A symbol in a lambda expression is called free
</p></div>
</div>
<div id="outline-container-6" class="outline-2">
<h2 id="sec-6"><span class="section-number-2">6</span> Combinators</h2>
<div class="outline-text-2" id="text-6">
</div>
</div>
<div id="outline-container-7" class="outline-2">
<h2 id="sec-7"><span class="section-number-2">7</span> Recursion</h2>
<div class="outline-text-2" id="text-7">
</div>
</div>
<div id="outline-container-8" class="outline-2">
<h2 id="sec-8"><span class="section-number-2">8</span> Lists</h2>
<div class="outline-text-2" id="text-8">
</div>
</div>
<div id="outline-container-9" class="outline-2">
<h2 id="sec-9"><span class="section-number-2">9</span> Javascript</h2>
<div class="outline-text-2" id="text-9">
</div>
</div>
<div id="outline-container-10" class="outline-2">
<h2 id="sec-10"><span class="section-number-2">10</span> Groovy</h2>
<div class="outline-text-2" id="text-10">
</div>
</div>
<div id="outline-container-11" class="outline-2">
<h2 id="sec-11"><span class="section-number-2">11</span> Monads</h2>
<div class="outline-text-2" id="text-11">
<p> Monads are a hot topic in today's programming scene. They are an
escapee from Category Theory, which is a kind of meta-mathemeatics.
</p>
</div>
<div id="outline-container-11-1" class="outline-3">
<h3 id="sec-11-1"><span class="section-number-3">11.1</span> IO monad</h3>
<div class="outline-text-3" id="text-11-1">
<p>Real-world programming requires side-effects, which is a big problem for
strictly functional languages, like Haskell, that enforce immutability.
They found a loophole by introducing the IO monad, which can be turned into
a list of instructions for creating the output.
</p></div>
</div>
<div id="outline-container-11-2" class="outline-3">
<h3 id="sec-11-2"><span class="section-number-3">11.2</span> Maybe monad</h3>
<div class="outline-text-3" id="text-11-2">
</div>
</div>
<div id="outline-container-11-3" class="outline-3">
<h3 id="sec-11-3"><span class="section-number-3">11.3</span> Promises</h3>
<div class="outline-text-3" id="text-11-3">
</div>
</div>
</div>
<div id="outline-container-12" class="outline-2">
<h2 id="sec-12"><span class="section-number-2">12</span> Notes</h2>
<div class="outline-text-2" id="text-12">
<ul>
<li><a href="http://marakana.com/s/post/1118/jquery_plugins">Develop your own jQuery plugin</a>
</li>
<li><a href="http://marakana.com/s/post/1127/jquery_web_page_presentation">Transform your web page into a presentation with jQuery</a>
</li>
</ul>
</div>
</div>
</div>
<div id="postamble">
<p class="date">Date: 2013-05-13 17:09:27 Eastern Daylight Time</p>
<p class="author">Author: Ed Cole</p>
<p class="creator">Org version 7.8.11 with Emacs version 24</p>
<a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a>
</div>
</body>
</html>