1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > Haskell zine: list comprehensions</ title >
6
+ < style > @font-face {font-family : 'threemedium' ;src : url ('https://alicja.dev/assets/fonts/three.eot' );src : url ('https://alicja.dev/assets/fonts/three.eot?#iefix' ) format ('embedded-opentype' ), url ('https://alicja.dev/assets/fonts/three.woff2' ) format ('woff2' ), url ('https://alicja.dev/assets/fonts/three.woff' ) format ('woff' ), url ('https://alicja.dev/assets/fonts/three.ttf' ) format ('truetype' ), url ('https://alicja.dev/assets/fonts/three.svg#threemedium' ) format ('svg' );font-weight : normal;font-style : normal}body {font : 18px "Trebuchet MS" , Helvetica, sans-serif;font : 32px "threemedium" ;margin-top : 20px ;text-align : right}input [type = "checkbox" ], input [type = "radio" ]{position : absolute;visibility : hidden}# trebuchet + label , # three + label {margin-right : 30px ;cursor : pointer;color : # 000 }# trebuchet + label {font : 18px "Trebuchet MS" , Helvetica, sans-serif}# three + label {font : 32px "threemedium" }# three : checked + .three-label {color : # b2b3b8 ;display : none}# trebuchet : checked + .trebuchet-label {color : # b2b3b8 ;display : none}# three : checked ~ .zine {font : 32px "threemedium" }# trebuchet : checked ~ .zine {font : 18px "Trebuchet MS" , Helvetica, sans-serif}.zine {margin : 0 auto;max-width : 840px ;text-align : left}@media print{@page { size : auto portrait; margin : 0cm ; }.zine { margin : 1cm ; -webkit-print-color-adjust : exact; }# trebuchet + label , # three + label { display : none; }}.output {color : # 8f4898 }.input {color : # ee4266 }.predicative {color : # 009fb7 }.comprehension-example {font-size : 1.3em ;margin-bottom : 10px }.comprehension , .element , .operator , .comment , .aside {display : inline-block}.element , .comment {width : 150px ;text-align : center}.comment {vertical-align : top;font-size : 0.8em ;margin-left : 5px }.operator {width : 5px }.aside {margin : 20px 0 0 210px }</ style >
7
+ </ head >
8
+ < body >
9
+ < input id ="trebuchet " type ="radio " name ="font ">
10
+ < label for ="trebuchet " class ="font-button trebuchet-label "> Trebuchet</ label >
11
+
12
+ < input id ="three " type ="radio " name ="font " checked >
13
+ < label for ="three " class ="font-button three-label "> Three</ label >
14
+
15
+ < div class ="zine ">
16
+ < h2 class ="comprehension-title "> Haskell list comprehensions - let's make some lists!</ h2 >
17
+
18
+ < div class ="comprehension-line ">
19
+ < div class ="comprehension ">
20
+ < div class ="comprehension-example ">
21
+ < span class ="operator "> [</ span >
22
+ < span class ="element output "> output function</ span >
23
+ < span class ="operator "> |</ span >
24
+ < span class ="element input "> input set*</ span >
25
+ < span class ="operator "> ,</ span >
26
+ < span class ="element predicative "> predicative*</ span >
27
+ < span class ="operator "> ]</ span >
28
+ </ div >
29
+ < div class ="comprehension-comments ">
30
+ < span class ="operator "> </ span >
31
+ < span class ="comment "> applied to members of the resulting list</ span >
32
+ < span class ="operator "> </ span >
33
+ < span class ="comment "> what we're generating the list from</ span >
34
+ < span class ="operator "> </ span >
35
+ < span class ="comment "> conditions that apply to input set values</ span >
36
+ < span class ="operator "> </ span >
37
+ </ div >
38
+ </ div >
39
+ </ div >
40
+
41
+ < span class ="aside ">
42
+ *can use multiple
43
+ < span class ="input "> input sets</ span > and
44
+ < span class ="predicative "> predicatives</ span >
45
+ </ span >
46
+ < h3 > A list of squares from 1 to 10: [1,4,9,16,25,36,49,64,81,100]</ h3 >
47
+
48
+ < div class ="comprehension-line ">
49
+ < div class ="comprehension ">
50
+ < div class ="comprehension-example ">
51
+ < span class ="operator "> [</ span >
52
+ < span class ="element output "> x ^ 2</ span >
53
+ < span class ="operator "> |</ span >
54
+ < span class ="element input "> x < - [1..10] </ span >
55
+ < span class ="operator "> ]</ span >
56
+ </ div >
57
+ < div class ="comprehension-comments ">
58
+ < span class ="operator "> </ span >
59
+ < span class ="comment "> 2. add a square of each</ span >
60
+ < span class ="operator "> </ span >
61
+ < span class ="comment "> 1. take numbers 1-10</ span >
62
+ < span class ="operator "> </ span >
63
+ < span class ="comment "> </ span >
64
+ </ div >
65
+ </ div >
66
+ </ div >
67
+ < h3 > A list of squares of even numbers between 1 and 10: : [4,16,36,64,100]</ h3 >
68
+
69
+ < div class ="comprehension-line ">
70
+ < div class ="comprehension ">
71
+ < div class ="comprehension-example ">
72
+ < span class ="operator "> [</ span >
73
+ < span class ="element output "> x ^ 2</ span >
74
+ < span class ="operator "> |</ span >
75
+ < span class ="element input "> x < - [1..10] </ span >
76
+ < span class ="operator "> ,</ span >
77
+ < span class ="element predicative "> rem x 2 == 0</ span >
78
+ < span class ="operator "> ]</ span >
79
+ </ div >
80
+ < div class ="comprehension-comments ">
81
+ < span class ="operator "> </ span >
82
+ < span class ="comment "> 3. if it's even - add a square of it</ span >
83
+ < span class ="operator "> </ span >
84
+ < span class ="comment "> 1. take numbers 1-10</ span >
85
+ < span class ="operator "> </ span >
86
+ < span class ="comment "> 2. for each check if it's even</ span >
87
+ < span class ="operator "> </ span >
88
+ </ div >
89
+ </ div >
90
+ </ div >
91
+ < h3 > A list of squares and cubes of even numbers between 1 and 5: [4,8,16,64]</ h3 >
92
+
93
+ < div class ="comprehension-line ">
94
+ < div class ="comprehension ">
95
+ < div class ="comprehension-example ">
96
+ < span class ="operator "> [</ span >
97
+ < span class ="element output "> x ^ y</ span >
98
+ < span class ="operator "> |</ span >
99
+ < span class ="element input "> x < - [1..5] </ span >
100
+ < span class ="operator "> ,</ span >
101
+ < span class ="element input "> y < - [2, 3] </ span >
102
+ < span class ="operator "> ,</ span >
103
+ < span class ="element predicative "> rem x 2 == 0</ span >
104
+ < span class ="operator "> ]</ span >
105
+ </ div >
106
+ < div class ="comprehension-comments ">
107
+ < span class ="operator "> </ span >
108
+ < span class ="comment "> 3. if it is - add first a square and then a cube of it</ span >
109
+ < span class ="operator "> </ span >
110
+ < span class ="comment "> 1. take numbers 1-5</ span >
111
+ < span class ="operator "> </ span >
112
+ < span class ="comment "> </ span >
113
+ < span class ="operator "> </ span >
114
+ < span class ="comment "> 2. for each check if it's even</ span >
115
+ < span class ="operator "> </ span >
116
+ </ div >
117
+ </ div >
118
+ </ div >
119
+ </ div >
120
+ </ body >
121
+ </ html >
0 commit comments