@explorable-viz/fluid 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/article/app.js +40580 -0
  4. package/dist/article/css/styles.css +191 -0
  5. package/dist/article/css/view-styles.css +141 -0
  6. package/dist/article/fluid/dataset/renewables-restricted.fld +139 -0
  7. package/dist/article/fluid/example/arithmetic.fld +1 -0
  8. package/dist/article/fluid/example/array.fld +2 -0
  9. package/dist/article/fluid/example/compose.fld +2 -0
  10. package/dist/article/fluid/example/desugar/list-comp-1.fld +1 -0
  11. package/dist/article/fluid/example/desugar/list-comp-10.fld +1 -0
  12. package/dist/article/fluid/example/desugar/list-comp-2.fld +1 -0
  13. package/dist/article/fluid/example/desugar/list-comp-3.fld +1 -0
  14. package/dist/article/fluid/example/desugar/list-comp-4.fld +1 -0
  15. package/dist/article/fluid/example/desugar/list-comp-5.fld +1 -0
  16. package/dist/article/fluid/example/desugar/list-comp-6.fld +1 -0
  17. package/dist/article/fluid/example/desugar/list-comp-7.fld +1 -0
  18. package/dist/article/fluid/example/desugar/list-comp-8.fld +1 -0
  19. package/dist/article/fluid/example/desugar/list-comp-9.fld +1 -0
  20. package/dist/article/fluid/example/desugar/list-enum.fld +1 -0
  21. package/dist/article/fluid/example/dicts.fld +11 -0
  22. package/dist/article/fluid/example/div-mod-quot-rem.fld +4 -0
  23. package/dist/article/fluid/example/factorial.fld +6 -0
  24. package/dist/article/fluid/example/filter.fld +1 -0
  25. package/dist/article/fluid/example/first-class-constr.fld +1 -0
  26. package/dist/article/fluid/example/flatten.fld +12 -0
  27. package/dist/article/fluid/example/foldr-sumSquares.fld +1 -0
  28. package/dist/article/fluid/example/graphics/background.fld +7 -0
  29. package/dist/article/fluid/example/graphics/grouped-bar-chart.fld +9 -0
  30. package/dist/article/fluid/example/graphics/line-chart.fld +13 -0
  31. package/dist/article/fluid/example/graphics/small-barchart.fld +5 -0
  32. package/dist/article/fluid/example/graphics/stacked-bar-chart.fld +3 -0
  33. package/dist/article/fluid/example/include-input-into-output.fld +1 -0
  34. package/dist/article/fluid/example/length.fld +1 -0
  35. package/dist/article/fluid/example/lexicalScoping.fld +3 -0
  36. package/dist/article/fluid/example/lib/some-constants.fld +1 -0
  37. package/dist/article/fluid/example/linked-inputs/energyscatter.fld +24 -0
  38. package/dist/article/fluid/example/linked-inputs/mini-energyscatter.fld +30 -0
  39. package/dist/article/fluid/example/linked-inputs/mini-non-renewables.fld +3 -0
  40. package/dist/article/fluid/example/linked-inputs/mini-renewables.fld +6 -0
  41. package/dist/article/fluid/example/linked-inputs/non-renewables.fld +67 -0
  42. package/dist/article/fluid/example/linked-inputs/renewables.fld +301 -0
  43. package/dist/article/fluid/example/linked-outputs/bar-chart-line-chart.expect.fld +0 -0
  44. package/dist/article/fluid/example/linked-outputs/bar-chart-line-chart.fld +26 -0
  45. package/dist/article/fluid/example/linked-outputs/convolution-data.fld +5 -0
  46. package/dist/article/fluid/example/linked-outputs/convolution.fld +12 -0
  47. package/dist/article/fluid/example/linked-outputs/line-chart.fld +13 -0
  48. package/dist/article/fluid/example/linked-outputs/moving-average-data.fld +9 -0
  49. package/dist/article/fluid/example/linked-outputs/moving-average.fld +15 -0
  50. package/dist/article/fluid/example/linked-outputs/pairs-data.fld +1 -0
  51. package/dist/article/fluid/example/linked-outputs/pairs.fld +3 -0
  52. package/dist/article/fluid/example/linked-outputs/renewables.fld +100 -0
  53. package/dist/article/fluid/example/linked-outputs/stacked-bar-chart-scatter-plot.fld +38 -0
  54. package/dist/article/fluid/example/lookup.fld +15 -0
  55. package/dist/article/fluid/example/map.fld +1 -0
  56. package/dist/article/fluid/example/mergeSort.fld +22 -0
  57. package/dist/article/fluid/example/normalise.fld +3 -0
  58. package/dist/article/fluid/example/nub.fld +1 -0
  59. package/dist/article/fluid/example/pattern-match.fld +12 -0
  60. package/dist/article/fluid/example/range.fld +4 -0
  61. package/dist/article/fluid/example/record-lookup.fld +3 -0
  62. package/dist/article/fluid/example/records.fld +11 -0
  63. package/dist/article/fluid/example/reverse.fld +1 -0
  64. package/dist/article/fluid/example/scratchpad.fld +6 -0
  65. package/dist/article/fluid/example/slicing/add.expect.fld +1 -0
  66. package/dist/article/fluid/example/slicing/add.fld +1 -0
  67. package/dist/article/fluid/example/slicing/array/array.expect.fld +2 -0
  68. package/dist/article/fluid/example/slicing/array/array.fld +4 -0
  69. package/dist/article/fluid/example/slicing/array/dims.expect.fld +3 -0
  70. package/dist/article/fluid/example/slicing/array/dims.fld +3 -0
  71. package/dist/article/fluid/example/slicing/array/lookup.expect.fld +3 -0
  72. package/dist/article/fluid/example/slicing/array/lookup.fld +5 -0
  73. package/dist/article/fluid/example/slicing/convolution/edgeDetect.expect.fld +1 -0
  74. package/dist/article/fluid/example/slicing/convolution/edgeDetect.fld +1 -0
  75. package/dist/article/fluid/example/slicing/convolution/emboss-wrap.fld +1 -0
  76. package/dist/article/fluid/example/slicing/convolution/emboss.expect.fld +1 -0
  77. package/dist/article/fluid/example/slicing/convolution/emboss.fld +1 -0
  78. package/dist/article/fluid/example/slicing/convolution/filter/edge-detect.fld +5 -0
  79. package/dist/article/fluid/example/slicing/convolution/filter/emboss.fld +5 -0
  80. package/dist/article/fluid/example/slicing/convolution/filter/gaussian.fld +5 -0
  81. package/dist/article/fluid/example/slicing/convolution/gaussian.expect.fld +1 -0
  82. package/dist/article/fluid/example/slicing/convolution/gaussian.fld +1 -0
  83. package/dist/article/fluid/example/slicing/convolution/test-image.fld +7 -0
  84. package/dist/article/fluid/example/slicing/dict/create.expect.fld +1 -0
  85. package/dist/article/fluid/example/slicing/dict/create.fld +1 -0
  86. package/dist/article/fluid/example/slicing/dict/difference.expect.fld +3 -0
  87. package/dist/article/fluid/example/slicing/dict/difference.fld +3 -0
  88. package/dist/article/fluid/example/slicing/dict/disjointUnion.expect.fld +1 -0
  89. package/dist/article/fluid/example/slicing/dict/disjointUnion.fld +1 -0
  90. package/dist/article/fluid/example/slicing/dict/foldl.expect.fld +1 -0
  91. package/dist/article/fluid/example/slicing/dict/foldl.fld +1 -0
  92. package/dist/article/fluid/example/slicing/dict/fromRecord.expect.fld +2 -0
  93. package/dist/article/fluid/example/slicing/dict/fromRecord.fld +1 -0
  94. package/dist/article/fluid/example/slicing/dict/get.expect.fld +3 -0
  95. package/dist/article/fluid/example/slicing/dict/get.fld +2 -0
  96. package/dist/article/fluid/example/slicing/dict/intersectionWith.expect.fld +2 -0
  97. package/dist/article/fluid/example/slicing/dict/intersectionWith.fld +4 -0
  98. package/dist/article/fluid/example/slicing/dict/map.expect.fld +6 -0
  99. package/dist/article/fluid/example/slicing/dict/map.fld +5 -0
  100. package/dist/article/fluid/example/slicing/divide.expect.fld +1 -0
  101. package/dist/article/fluid/example/slicing/divide.fld +1 -0
  102. package/dist/article/fluid/example/slicing/dtw/average-series.expect.fld +8 -0
  103. package/dist/article/fluid/example/slicing/dtw/average-series.fld +8 -0
  104. package/dist/article/fluid/example/slicing/dtw/compute-dtw.expect.fld +6 -0
  105. package/dist/article/fluid/example/slicing/dtw/compute-dtw.fld +6 -0
  106. package/dist/article/fluid/example/slicing/filter.expect.fld +4 -0
  107. package/dist/article/fluid/example/slicing/filter.fld +6 -0
  108. package/dist/article/fluid/example/slicing/intersperse-1.expect.fld +4 -0
  109. package/dist/article/fluid/example/slicing/intersperse-2.expect.fld +4 -0
  110. package/dist/article/fluid/example/slicing/intersperse.fld +5 -0
  111. package/dist/article/fluid/example/slicing/length.expect.fld +1 -0
  112. package/dist/article/fluid/example/slicing/length.fld +1 -0
  113. package/dist/article/fluid/example/slicing/linked-outputs/bar-chart-line-chart.expect.fld +0 -0
  114. package/dist/article/fluid/example/slicing/linked-outputs/bar-chart-line-chart.fld +26 -0
  115. package/dist/article/fluid/example/slicing/linked-outputs/renewables.fld +100 -0
  116. package/dist/article/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.expect.fld +0 -0
  117. package/dist/article/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.fld +38 -0
  118. package/dist/article/fluid/example/slicing/list-comp-1.expect.fld +6 -0
  119. package/dist/article/fluid/example/slicing/list-comp-2.expect.fld +6 -0
  120. package/dist/article/fluid/example/slicing/list-comp.fld +8 -0
  121. package/dist/article/fluid/example/slicing/lookup.expect.fld +6 -0
  122. package/dist/article/fluid/example/slicing/lookup.fld +14 -0
  123. package/dist/article/fluid/example/slicing/map.expect.fld +1 -0
  124. package/dist/article/fluid/example/slicing/map.fld +1 -0
  125. package/dist/article/fluid/example/slicing/matrix-update.expect.fld +5 -0
  126. package/dist/article/fluid/example/slicing/matrix-update.fld +10 -0
  127. package/dist/article/fluid/example/slicing/multiply.expect.fld +1 -0
  128. package/dist/article/fluid/example/slicing/multiply.fld +1 -0
  129. package/dist/article/fluid/example/slicing/nth.expect.fld +1 -0
  130. package/dist/article/fluid/example/slicing/nth.fld +1 -0
  131. package/dist/article/fluid/example/slicing/output-not-source.expect.fld +2 -0
  132. package/dist/article/fluid/example/slicing/output-not-source.fld +1 -0
  133. package/dist/article/fluid/example/slicing/section-5-example-1.expect.fld +10 -0
  134. package/dist/article/fluid/example/slicing/section-5-example-2.expect.fld +10 -0
  135. package/dist/article/fluid/example/slicing/section-5-example-3.expect.fld +10 -0
  136. package/dist/article/fluid/example/slicing/section-5-example.fld +14 -0
  137. package/dist/article/fluid/example/slicing/zeros-1.expect.fld +3 -0
  138. package/dist/article/fluid/example/slicing/zeros-2.expect.fld +3 -0
  139. package/dist/article/fluid/example/slicing/zeros.fld +4 -0
  140. package/dist/article/fluid/example/slicing/zipWith-1.expect.fld +4 -0
  141. package/dist/article/fluid/example/slicing/zipWith.fld +4 -0
  142. package/dist/article/fluid/example/text.fld +27 -0
  143. package/dist/article/fluid/lib/convolution.fld +16 -0
  144. package/dist/article/fluid/lib/dtw.fld +47 -0
  145. package/dist/article/fluid/lib/fnum.fld +22 -0
  146. package/dist/article/fluid/lib/graphics.fld +221 -0
  147. package/dist/article/fluid/lib/moving-average.fld +35 -0
  148. package/dist/article/fluid/lib/nombre.fld +14 -0
  149. package/dist/article/fluid/lib/prelude.fld +246 -0
  150. package/dist/article/index.html +44 -0
  151. package/fluid.js +46 -0
  152. package/package.json +80 -0
@@ -0,0 +1,191 @@
1
+ @charset "UTF-8";
2
+ @font-face {
3
+ font-family: "Fira Code";
4
+ src: url("https://fonts.googleapis.com/css2?family=Fira+Code&display=swap");
5
+ }
6
+
7
+ .glowing, a {
8
+ transition: all .25s;
9
+ }
10
+
11
+ a:hover {
12
+ text-shadow: 0 0 2px #FFF, 0 0 5px #A0A0FF, 0 0 7px #8080A0;
13
+ }
14
+
15
+ .nowrap {
16
+ white-space: nowrap;
17
+ }
18
+
19
+ code {
20
+ font-size: 11pt;
21
+ }
22
+
23
+ body {
24
+ font-size: 11pt;
25
+ font-family: "Roboto", sans-serif;
26
+ font-weight: 300;
27
+ line-height: 1.25;
28
+ padding: 0;
29
+ margin: 0;
30
+ background-color: #FFFFFF; /* #181818; */
31
+ color: #404040;
32
+ margin-bottom: 10em;
33
+ }
34
+
35
+ .center {
36
+ height: 100%;
37
+ }
38
+
39
+ .align-right {
40
+ text-align: right;
41
+ }
42
+
43
+ .title {
44
+ color: darkblue;
45
+ }
46
+
47
+ h3 {
48
+ font-family: "Roboto", sans-serif;
49
+ font-weight: 600;
50
+ margin-top: 10pt;
51
+ margin-bottom: 0;
52
+ font-size: '24px'
53
+ }
54
+
55
+ h4 {
56
+ margin-top: 10pt;
57
+ margin-block-start: 1em;
58
+ margin-bottom: 0;
59
+ }
60
+
61
+ .glowing {
62
+ transition-timing-function: ease-out
63
+ }
64
+
65
+ a {
66
+ text-decoration: none;
67
+ color: inherit;
68
+ transition-timing-function: ease-out
69
+ }
70
+
71
+ a.not_decorated,
72
+ a:hover {
73
+ text-decoration: none;
74
+ }
75
+
76
+ ul {
77
+ padding-left: 0
78
+ }
79
+
80
+ li {
81
+ margin-bottom: 1ex
82
+ }
83
+
84
+ li:last-child {
85
+ margin-bottom: 0
86
+ }
87
+
88
+ table {
89
+ margin: 4mm;
90
+ }
91
+
92
+ .table-caption {
93
+ text-align: left;
94
+ }
95
+
96
+ th {
97
+ font-size: 11px;
98
+ text-align: left;
99
+ border-bottom: 'thin solid';
100
+ }
101
+
102
+ td {
103
+ font-size: 11px;
104
+ }
105
+
106
+ td:nth-child(1) {
107
+ color: lightgray;
108
+ }
109
+
110
+ nav ul {
111
+ list-style: none;
112
+ }
113
+
114
+ nav ul li {
115
+ float: left;
116
+ overflow: hidden;
117
+ }
118
+
119
+ nav ul li a {
120
+ display: block;
121
+ width: 100%;
122
+ text-align: left;
123
+ padding-right: 8px;
124
+ text-decoration: none;
125
+ }
126
+
127
+ nav ul li a.active-page {
128
+ text-shadow: 0 0 2px #FFF, 0 0 5px #A0A0FF, 0 0 7px #8080A0;
129
+ }
130
+
131
+ .cm-line {
132
+ font-family: 'Fira Code';
133
+ font-size: 8pt;
134
+ }
135
+
136
+ .grid-container {
137
+ display: grid;
138
+ width: 100%;
139
+ grid-template-columns: 10px 47.5% fit-content(10px) 47.5%;
140
+ }
141
+
142
+ .flex-left-align {
143
+ display: flex;
144
+ flex-direction: column;
145
+ align-items: start;
146
+ }
147
+
148
+ .flex-right-align {
149
+ display: flex;
150
+ flex-direction: column;
151
+ align-items: flex-end;
152
+ }
153
+
154
+ .flex-bottom-align {
155
+ display: flex;
156
+ flex-direction: row;
157
+ align-items: flex-end;
158
+ }
159
+
160
+ .data-pane-button {
161
+ font-size: 9pt;
162
+ }
163
+
164
+ .toggle-button {
165
+ color: #CCCCCC;
166
+ user-select: none;
167
+ }
168
+
169
+ .toggle-button:hover {
170
+ color: #999999;
171
+ }
172
+
173
+ .data-pane {
174
+ background-color: #F5F5F5;
175
+ }
176
+
177
+ /* Standalone figures have hardcoded zoom for presentation purposes. */
178
+ .double-size {
179
+ zoom: 1.8;
180
+ }
181
+
182
+ body.standalone {
183
+ height: 100%;
184
+ display: grid; /* outer grid for vertical centering of inner */
185
+ place-items: center;
186
+ }
187
+
188
+ /* Needed for contained height specifications to work */
189
+ html {
190
+ height: 100%;
191
+ }
@@ -0,0 +1,141 @@
1
+ table {
2
+ border-collapse: collapse;
3
+ border-spacing: 0px;
4
+ }
5
+
6
+ thead {
7
+ border-top: 0.5px solid lightgray;
8
+ }
9
+
10
+ .legend-box {
11
+ stroke: lightgray;
12
+ stroke-width: 0.5px;
13
+ fill: none;
14
+ }
15
+
16
+ .title-text {
17
+ fill: Black;
18
+ font-size: 9pt;
19
+ font-family: "Roboto", sans-serif;
20
+ }
21
+
22
+ .table-row {
23
+ display: table-row;
24
+ }
25
+
26
+ .table-cell {
27
+ border-radius: 2px;
28
+ background-color: White;
29
+ border-left: 2px solid white;
30
+ }
31
+
32
+ .table-cell.selected-primary-persistent {
33
+ background-color: #93E9BE;
34
+ }
35
+
36
+ .table-cell.selected-primary-transient {
37
+ border-left: 2px solid blue;
38
+ }
39
+
40
+ .table-cell.selected-secondary-persistent {
41
+ background-color: rgb(226, 226, 226);
42
+ }
43
+
44
+ .table-cell.selected-secondary-transient {
45
+ border-left: 2px solid lightblue;
46
+ }
47
+
48
+ .linked-text {
49
+ border-radius: 0px;
50
+ background-color: White;
51
+ border-bottom-style: solid;
52
+ border-bottom-color: white;
53
+ border-bottom-width: 1px;
54
+ display: inline;
55
+ }
56
+
57
+ .linked-text.selected-primary-persistent {
58
+ background-color: #93E9BE;
59
+ }
60
+
61
+ .linked-text.selected-primary-transient {
62
+ border-bottom-color: blue;
63
+ }
64
+
65
+ .linked-text.selected-secondary-persistent {
66
+ background-color: rgb(226, 226, 226);
67
+ }
68
+
69
+ .linked-text.selected-secondary-transient {
70
+ border-bottom-color: lightblue;
71
+ }
72
+
73
+ .table-row.hidden {
74
+ visibility: collapse;
75
+ }
76
+
77
+ .matrix-cell {
78
+ stroke: DarkGray;
79
+ fill: White;
80
+ }
81
+
82
+ .matrix-cell.selected-primary-persistent {
83
+ fill: LightGreen;
84
+ }
85
+
86
+ .matrix-cell.selected-secondary-persistent {
87
+ fill: rgb(214, 240, 214)
88
+ }
89
+
90
+ .matrix-cell.selected-primary-transient {
91
+ }
92
+
93
+ .matrix-cell.selected-secondary-transient {
94
+ }
95
+
96
+ .matrix-cell-text {
97
+ font-size: 10pt;
98
+ font-family: "Roboto", sans-serif;
99
+ color: rgb(205, 205, 205)
100
+ }
101
+
102
+ .matrix-cell-text.selected-primary-persistent {
103
+ font-weight: 400;
104
+ color: darkgreen
105
+ }
106
+
107
+ .matrix-cell-text.selected-secondary-persistent {
108
+ color: green
109
+ }
110
+
111
+ .matrix-cell-text.selected-primary-transient {
112
+ font-weight: 400;
113
+ color: blue
114
+ }
115
+
116
+ .matrix-cell-text.selected-secondary-transient {
117
+ color: royalblue
118
+ }
119
+
120
+ .scatterplot-point {
121
+ fill: white;
122
+ stroke: black;
123
+ }
124
+
125
+ .scatterplot-point.selected-primary-persistent {
126
+ fill: LightGreen;
127
+ stroke: teal;
128
+ }
129
+
130
+ .scatterplot-point.selected-primary-transient {
131
+ stroke: blue;
132
+ stroke-width: 1;
133
+ }
134
+
135
+ .scatterplot-point.selected-secondary-persistent {
136
+ fill: rgb(226, 226, 226);
137
+ }
138
+
139
+ .scatterplot-point.selected-secondary-transient {
140
+ stroke-width: 1;
141
+ }
@@ -0,0 +1,139 @@
1
+ -- typedef Year = Num
2
+ -- typedef Country = Str
3
+ -- typedef EnergyType = Str
4
+ -- typedef Output = Num
5
+ -- typedef CountryData = List (EnergyType, Output)
6
+ -- typedef AnnualData = List (Country, CountryData)
7
+ -- typedef Data = List (Year, AnnualData)
8
+ -- The original dataset sometimes has '~0' instead of '0'.
9
+
10
+ -- Including only 3 countries here. Also, have reduced the Hydro value for China 2015 from 296 to 96 (ouch)
11
+ -- to make the charts fit nicely into my grant proposal. Fix this once proposal submitted!
12
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2014_Full-Report_English.pdf
13
+ [
14
+ (2013, [
15
+ ("China", [
16
+ ("Bio", 6.2),
17
+ ("Hydro", 260),
18
+ ("Solar", 19.9),
19
+ ("Wind", 91)
20
+ ]),
21
+ ("USA", [
22
+ ("Bio", 15.8),
23
+ ("Hydro", 78),
24
+ ("Solar", 12.1),
25
+ ("Wind", 61)
26
+ ]),
27
+ ("Germany", [
28
+ ("Bio", 8.1),
29
+ ("Hydro", 5.6),
30
+ ("Solar", 36),
31
+ ("Wind", 34)
32
+ ])
33
+ ]),
34
+ -- https://www.ren21.net/wp-content/uploads/2019/05/GSR2015_Full-Report_English.pdf
35
+ (2014, [
36
+ ("China", [
37
+ ("Bio", 10),
38
+ ("Hydro", 280),
39
+ ("Solar", 28),
40
+ ("Wind", 115)
41
+ ]),
42
+ ("USA", [
43
+ ("Bio", 16.1),
44
+ ("Hydro", 79),
45
+ ("Solar", 18),
46
+ ("Wind", 66)
47
+ ]),
48
+ ("Germany", [
49
+ ("Bio", 8.8),
50
+ ("Hydro", 5.6),
51
+ ("Solar", 38),
52
+ ("Wind", 39)
53
+ ])
54
+ ]),
55
+ -- https://www.ren21.net/gsr-2016/00-Reference-Tables.php
56
+ (2015, [
57
+ ("China", [
58
+ ("Bio", 10.3),
59
+ ("Hydro", 96),
60
+ ("Solar", 44),
61
+ ("Wind", 145)
62
+ ]),
63
+ ("USA", [
64
+ ("Bio", 16.7),
65
+ ("Hydro", 80),
66
+ ("Solar", 26),
67
+ ("Wind", 74)
68
+ ]),
69
+ ("Germany", [
70
+ ("Bio", 7.1),
71
+ ("Hydro", 5.6),
72
+ ("Solar", 40),
73
+ ("Wind", 45)
74
+ ])
75
+ ]),
76
+ -- https://www.ren21.net/gsr-2017/pages/tables/tables/#table-R2
77
+ (2016, [
78
+ ("China", [
79
+ ("Bio", 12),
80
+ ("Hydro", 305),
81
+ ("Solar", 77),
82
+ ("Wind", 169)
83
+ ]),
84
+ ("USA", [
85
+ ("Bio", 16.8),
86
+ ("Hydro", 80),
87
+ ("Solar", 41),
88
+ ("Wind", 82)
89
+ ]),
90
+ ("Germany", [
91
+ ("Bio", 7.6),
92
+ ("Hydro", 5.6),
93
+ ("Solar", 41),
94
+ ("Wind", 50)
95
+ ])
96
+ ]),
97
+ -- https://www.ren21.net/gsr-2018/pages/tables/tables/#Table_R2
98
+ (2017, [
99
+ ("China", [
100
+ ("Bio", 14.9),
101
+ ("Hydro", 313),
102
+ ("Solar", 131),
103
+ ("Wind", 188)
104
+ ]),
105
+ ("USA", [
106
+ ("Bio", 16.7),
107
+ ("Hydro", 80),
108
+ ("Solar", 51),
109
+ ("Wind", 89)
110
+ ]),
111
+ ("Germany", [
112
+ ("Bio", 8),
113
+ ("Hydro", 5.6),
114
+ ("Solar", 42),
115
+ ("Wind", 56)
116
+ ])
117
+ ]),
118
+ -- https://www.ren21.net/gsr-2019/tables/table_02/table_02/
119
+ (2018, [
120
+ ("China", [
121
+ ("Bio", 17.8),
122
+ ("Hydro", 322),
123
+ ("Solar", 176),
124
+ ("Wind", 210)
125
+ ]),
126
+ ("USA", [
127
+ ("Bio", 16.2),
128
+ ("Hydro", 80),
129
+ ("Solar", 62),
130
+ ("Wind", 96)
131
+ ]),
132
+ ("Germany", [
133
+ ("Bio", 8.4),
134
+ ("Hydro", 5.6),
135
+ ("Solar", 45),
136
+ ("Wind", 59)
137
+ ])
138
+ ])
139
+ ]
@@ -0,0 +1 @@
1
+ (1 + 5) * ((let x = 2; y = 8 in x * y) - (let y = 3 in y * y))
@@ -0,0 +1,2 @@
1
+ let xs = [| i * j | (i, j) in (3, 3) |]
2
+ in (xs ! (1, 1), dims xs)
@@ -0,0 +1,2 @@
1
+ let incr = (+) 1 in
2
+ (compose incr incr) 3
@@ -0,0 +1 @@
1
+ [ x + y | x <- [5, 4, 3], y <- [9, 7, 5] ]
@@ -0,0 +1 @@
1
+ [ x | [x] <- [[], [4, 6]] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], y <- [9, 7, 5], let z = x + y, c <- [9, 7, 5] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], y <- [9, 7, 5], let z = x + y, z < 10 ]
@@ -0,0 +1 @@
1
+ [ x | x : xs <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ z | x <- [5, 4, 3], let z = x ]
@@ -0,0 +1 @@
1
+ [ z | let z = 5 ]
@@ -0,0 +1 @@
1
+ [ [] | [] <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ x | [x] <- [[5], [4], [3], []] ]
@@ -0,0 +1 @@
1
+ [ x + y | [x, y] <- [[5], [4, 6], [3], [], [9, 10]] ]
@@ -0,0 +1,11 @@
1
+ let d = {||};
2
+ e = {| "a" := 5, "a" ++ "b" := 6 |};
3
+ f = {| "ab" := 12 |}
4
+ in {
5
+ d: d,
6
+ e: e,
7
+ e_ab: dict_get "ab" e,
8
+ f: dict_map ((+) 1) e,
9
+ g: dict_difference e f,
10
+ h: dict_fromRecord {fst: 4, snd: [6, 7]}
11
+ }
@@ -0,0 +1,4 @@
1
+ [[5 `div` 3, 5 `div` -3, -5 `div` 3, -5 `div` -3],
2
+ [5 `mod` 3, 5 `mod` -3, -5 `mod` 3, -5 `mod` -3],
3
+ [5 `quot` 3, 5 `quot` -3, -5 `quot` 3, -5 `quot` -3],
4
+ [5 `rem` 3, 5 `rem` -3, -5 `rem` 3, -5 `rem` -3]]
@@ -0,0 +1,6 @@
1
+ let fact x =
2
+ if x == 0
3
+ then 1
4
+ else x * fact (x - 1)
5
+ in
6
+ fact 8
@@ -0,0 +1 @@
1
+ filter ((<) 5) [8, 4, 7, 3]
@@ -0,0 +1 @@
1
+ zipWith (:) [10, 12, 20] [[], [], [], [], []]
@@ -0,0 +1,12 @@
1
+ let
2
+ flatten Empty = [];
3
+ flatten (NonEmpty t1 (key, val) t2) =
4
+ concat2 (flatten t1) ((key, val) : flatten t2)
5
+ in
6
+ flatten
7
+ (NonEmpty
8
+ (NonEmpty Empty (3, "simon") Empty)
9
+ (4, "john")
10
+ (NonEmpty (NonEmpty Empty (6, "sarah") Empty) (7, "claire") Empty)
11
+ )
12
+
@@ -0,0 +1 @@
1
+ foldr (fun x y -> x * x + y * y) 0 [6, 3, 2]
@@ -0,0 +1,7 @@
1
+ let rect = Rect 0 0 1 3 "red";
2
+ g = Group [Viewport 0 0 1 3 "white" 0 (Scale 1 1) (Translate 0 0) rect];
3
+ w = 1.0;
4
+ m = 0.25;
5
+ x_scale = max (w - 2 * m) 0 / w;
6
+ translate = Translate (m / x_scale) 0
7
+ in Viewport 0 0 w 3 "gray" 0 (Scale x_scale 1) translate g
@@ -0,0 +1,9 @@
1
+ let year = 2015;
2
+ -- List (Country, List (EnergyType, Output)) -> List (Country, List (EnergyType, Output))
3
+ let exclude countries yearData =
4
+ flip map yearData (second (filter (fun (country, countryData) -> not (elem country countries))))
5
+ in caption ("Renewables (GW) by country and energy type, " ++ numToStr year)
6
+ (groupedBarChart True colours1 0.2
7
+ (exclude
8
+ [] -- ["Geothermal", "Ocean", "CSP"]
9
+ (lookup year data)))
@@ -0,0 +1,13 @@
1
+ let year1 = head data;
2
+ -- List (EnergyType, Output) -> List (EnergyType, Output)
3
+ let addTotal kvs =
4
+ ("Total", sum (map snd kvs)) : kvs;
5
+ -- Country -> List (Year, List (EnergyType, Output))
6
+ let countryData country =
7
+ map (second (compose addTotal (lookup country))) data in
8
+ -- List Country
9
+ (fun country ->
10
+ caption country
11
+ (lineChart True ("black" : colours1) (fst year1)
12
+ (countryData country)))
13
+ "China"
@@ -0,0 +1,5 @@
1
+ let countryData = [ { x: "USA", bars: [ { y: "output", z: 196.7 } ] } ]
2
+ in BarChart {
3
+ caption: "Total output by country",
4
+ data: countryData
5
+ }
@@ -0,0 +1,3 @@
1
+ let year = 2015 in
2
+ caption ("Total renewables (GW) by country, " ++ numToStr year)
3
+ (stackedBarChart True colours1 0.2 (lookup year data))
@@ -0,0 +1 @@
1
+ length [2, 3]
@@ -0,0 +1,3 @@
1
+ let decr = let x = 2 in flip (-) x;
2
+ x = 8 in
3
+ numToStr (decr x)
@@ -0,0 +1 @@
1
+ let x = 1;
@@ -0,0 +1,24 @@
1
+ let isCountry name x = name == x.country;
2
+ isYear year x = year == x.year;
3
+
4
+ let plot year countries =
5
+ let rens = filter (isYear year) renewables;
6
+ nonRens = filter (isYear year) nonRenewables;
7
+ let plotCountry country =
8
+ let rens' = filter (isCountry country) rens;
9
+ rensOut = sum (map (fun x -> x.output) rens');
10
+ rensCap = sum (map (fun x -> x.capacity) rens');
11
+ x = head (filter (isCountry country) nonRens);
12
+ nonRensCap = x.nuclearCap + x.petrolCap + x.gasCap + x.coalCap
13
+ in {
14
+ x: rensCap / (rensCap + nonRensCap),
15
+ y: (rensOut + x.nuclearOut) / (rensCap + x.nuclearCap)
16
+ }
17
+ in map plotCountry countries
18
+
19
+ in ScatterPlot {
20
+ caption: "Clean energy efficiency vs. proportion of renewable energy capacity",
21
+ data: plot 2018 [ "BRA", "CHN", "DEU", "FRA", "EGY", "IND", "JPN", "MEX", "NGA", "USA" ],
22
+ xlabel: "Renewables/TotalEnergyCap",
23
+ ylabel: "Clean Capacity Factor"
24
+ }
@@ -0,0 +1,30 @@
1
+ let sumNonRenewables x = x.nuclearCap + x.petrolCap + x.gasCap + x.coalCap;
2
+ let country_check name x = name == x.country;
3
+ let year_check year x = year == x.year;
4
+
5
+ let energy year c_names =
6
+ let rens2018 = filter (year_check year) renewables;
7
+ let nonrens2018 = filter (year_check year) nonRenewables;
8
+ let energy_per_country c_name =
9
+ let filteredRen = filter (country_check c_name) rens2018;
10
+ let non_ren_x = head (filter (country_check c_name) nonrens2018);
11
+ let rensOut = sum (map (fun x = x.output) filteredRen);
12
+ let rensCap = sum (map (fun x = x.capacity) filteredRen);
13
+ let nonRensCap = sumNonRenewables non_ren_x
14
+ in {
15
+ name: c_name,
16
+ totalCap: rensCap + nonRensCap,
17
+ nonRenewables: nonRensCap,
18
+ renCapFactor: (rensOut + non_ren_x.nuclearOut) / (rensCap + non_ren_x.nuclearCap)
19
+ }
20
+ in
21
+ map energy_per_country c_names
22
+ in ScatterPlot {
23
+ caption: "Clean energy efficiency against proportion of renewable energy cap",
24
+ data: [{
25
+ x: country.nonRenewables / country.totalCap,
26
+ y: country.renCapFactor
27
+ }| country <- energy 2018 ["USA"]],
28
+ xlabel: "Renewables/TotalEnergyCap",
29
+ ylabel: "Clean Capacity Factor"
30
+ }
@@ -0,0 +1,3 @@
1
+ [
2
+ { country: "USA", year: 2018, nuclearOut: 807.08, nuclearCap: 871.01, gasOut: 1469.13, gasCap: 4431.51, coalOut: 1149.49, coalCap: 2293.89, petrolOut: 42.68, petrolCap: 304.67}
3
+ ]