@explorable-viz/fluid 0.9.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fluid/fluid/lib/pi.fld +1 -0
- package/dist/fluid/fluid/lib/prelude.fld +213 -251
- package/dist/fluid/shared/fluid.mjs +4585 -1030
- package/dist/fluid/shared/load-figure.js +4601 -7056
- package/dist/fluid/shared/webtest-lib.js +3958 -3958
- package/package.json +1 -1
- package/website/article/convolution/index.html +10 -3
- package/website/article/css/styles.css +5 -5
- package/website/article/fluid/1805.02474v1-10.fld +46 -0
- package/website/article/fluid/bar-chart-line-chart.fld +37 -0
- package/website/article/fluid/convolution/emboss.fld +3 -5
- package/website/article/fluid/convolution/testImage.fld +9 -7
- package/website/article/fluid/convolution.fld +25 -23
- package/website/article/fluid/dataset/renewable-new.json +91 -0
- package/website/article/fluid/dataset/scigen/1805.02474v1-10.json +17 -0
- package/website/article/fluid/dataset/scigen/_1805_02474v1_10.fld +2 -0
- package/website/article/fluid/methane.fld +1 -1
- package/website/article/fluid/moving-average.fld +22 -19
- package/website/article/fluid/non-renewables.fld +29 -21
- package/website/article/fluid/nonRenewables.fld +5 -2
- package/website/article/fluid/renewables.fld +1 -0
- package/website/article/fluid/scigen.fld +48 -0
- package/website/article/fluid/util.fld +39 -0
- package/website/article/index.html +3 -1
- package/website/article/moving-average/index.html +8 -2
- package/website/article/non-renewables/index.html +8 -2
- package/website/article/renewables-linked/index.html +60 -0
- package/website/article/scigen-1805.02474v1-10/index.html +50 -0
- package/website/article/test.mjs +5 -0
- package/website/article/convolution/spec.json +0 -6
- package/website/article/moving-average/spec.json +0 -6
- package/website/article/non-renewables/spec.json +0 -6
@@ -0,0 +1 @@
|
|
1
|
+
def pi: 3
|
@@ -1,276 +1,238 @@
|
|
1
|
-
|
1
|
+
def and(False, y): False
|
2
|
+
def and(True, y): y
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
and True y = y;
|
4
|
+
def or(True, y): True
|
5
|
+
def or(False, y): y
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
or False y = y;
|
7
|
+
def not(True): False
|
8
|
+
def not(False): True
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def compare(x, y):
|
11
|
+
if x > y: GT
|
12
|
+
else:
|
13
|
+
if x < y: LT
|
14
|
+
else: EQ
|
14
15
|
|
15
|
-
|
16
|
-
let compare x y =
|
17
|
-
if x > y
|
18
|
-
then GT
|
19
|
-
else if x < y
|
20
|
-
then LT
|
21
|
-
else EQ;
|
16
|
+
def negate: (-)(0)
|
22
17
|
|
23
|
-
|
24
|
-
let negate = (-) 0;
|
18
|
+
def logBase(x, y): log(y) / log(x)
|
25
19
|
|
26
|
-
|
27
|
-
-- Float -> Float -> Float
|
28
|
-
let logBase x y = log y / log x;
|
20
|
+
def ceilingToNearest(n, m): ceiling(n / m) * m
|
29
21
|
|
30
|
-
|
31
|
-
let ceilingToNearest n m =
|
32
|
-
ceiling (n / m) * m;
|
22
|
+
def compose(f, g, x): f(g(x))
|
33
23
|
|
34
|
-
|
35
|
-
-- Want infix <<<
|
36
|
-
let compose f g x = f (g x);
|
24
|
+
def curry(f, x, y): f((x, y))
|
37
25
|
|
38
|
-
|
39
|
-
let curry f x y = f (x, y);
|
26
|
+
def uncurry(f, (x, y)): f(x, y)
|
40
27
|
|
41
|
-
|
42
|
-
let uncurry f (x, y) = f x y;
|
28
|
+
def const(x, _): x
|
43
29
|
|
44
|
-
|
45
|
-
let const x _ = x;
|
30
|
+
def first(f, (a, c)): (f(a), c)
|
46
31
|
|
47
|
-
|
48
|
-
let first f (a, c) = (f a, c);
|
32
|
+
def snd((_, y)): y
|
49
33
|
|
50
|
-
|
51
|
-
let snd (_, y) = y;
|
34
|
+
def second(f, (c, a)): (c, f(a))
|
52
35
|
|
53
|
-
|
54
|
-
let second f (c, a) = (c, f a);
|
36
|
+
def flip(f, x, y): f(y, x)
|
55
37
|
|
56
|
-
|
57
|
-
let flip f x y = f y x;
|
38
|
+
def fst((x, _)): x
|
58
39
|
|
59
|
-
|
60
|
-
let fst (x, _) = x;
|
40
|
+
def id(x): x
|
61
41
|
|
62
|
-
|
63
|
-
let id x = x;
|
42
|
+
def prod(f, g, x): (f(x), g(x))
|
64
43
|
|
65
|
-
|
66
|
-
-- Want infix &&&
|
67
|
-
let prod f g x = (f x, g x);
|
44
|
+
def swap((a, b)): (b, a)
|
68
45
|
|
69
|
-
|
70
|
-
|
46
|
+
def head([]):
|
47
|
+
error("Can't take head of empty list")
|
48
|
+
def head(x :| _): x
|
71
49
|
|
72
|
-
|
73
|
-
|
74
|
-
|
50
|
+
def tail([]):
|
51
|
+
error("Can't take tail of empty list")
|
52
|
+
def tail(_ :| xs): xs
|
75
53
|
|
76
|
-
|
77
|
-
|
78
|
-
|
54
|
+
def elem(x, []): False
|
55
|
+
def elem(x, y :| xs):
|
56
|
+
x == y |or| elem(x, xs)
|
79
57
|
|
80
|
-
|
81
|
-
|
82
|
-
|
58
|
+
def find(p, []): error("not found")
|
59
|
+
def find(p, x :| xs):
|
60
|
+
if p(x): Some(x)
|
61
|
+
else: find(p, xs)
|
83
62
|
|
84
|
-
|
85
|
-
|
86
|
-
find p (x : xs) = if p x then Some x else find p xs;
|
63
|
+
def findWithKey(fname, fval, table):
|
64
|
+
find((lambda y: y[fname] == fval), table)
|
87
65
|
|
88
|
-
|
89
|
-
|
66
|
+
def fromSome(option):
|
67
|
+
match option:
|
68
|
+
case None:
|
69
|
+
error("Expected Some!")
|
70
|
+
case Some(x): x
|
90
71
|
|
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
|
-
-- Eq a => [a] -> [a]
|
259
|
-
let nub xs =
|
260
|
-
let nub' [] _ = [];
|
261
|
-
nub' (x : xs) ys = if x `elem` ys then nub' xs ys else x : nub' xs (x : ys) in
|
262
|
-
nub' xs [];
|
263
|
-
|
264
|
-
-- Int -> Int -> [a] -> [a]
|
265
|
-
let slice begin end xs =
|
266
|
-
take (end - begin) (drop begin xs);
|
267
|
-
|
268
|
-
|
269
|
-
-- (a -> Boolean) -> List a -> (List a, List a)
|
270
|
-
let splitOn p data =
|
271
|
-
let go fls trs [] = (reverse fls, reverse trs);
|
272
|
-
go fls trs (x : xs) =
|
273
|
-
if p x
|
274
|
-
then go fls (x : trs) xs
|
275
|
-
else go (x : fls) trs xs
|
276
|
-
in go [] [] data;
|
72
|
+
def filter(p, []): []
|
73
|
+
def filter(p, x :| xs):
|
74
|
+
def ys: filter(p, xs)
|
75
|
+
|
76
|
+
if p(x): x :| ys
|
77
|
+
else: ys
|
78
|
+
|
79
|
+
def filterMap(p, []): []
|
80
|
+
def filterMap(p, x :| xs):
|
81
|
+
match p(x):
|
82
|
+
case None: filterMap(f, xs)
|
83
|
+
case Some(y):
|
84
|
+
y :| filterMap(f, xs)
|
85
|
+
|
86
|
+
def foldl(op, z, []): z
|
87
|
+
def foldl(op, z, x :| xs):
|
88
|
+
foldl(op, op(z, x), xs)
|
89
|
+
|
90
|
+
def foldl1(op, x :| xs): foldl(op, x, xs)
|
91
|
+
|
92
|
+
def foldr(op, z, []): z
|
93
|
+
def foldr(op, z, x :| xs):
|
94
|
+
op(x, foldr(op, z, xs))
|
95
|
+
|
96
|
+
def foldr1(op, [x]): x
|
97
|
+
def foldr1(op, x :| y :| xs):
|
98
|
+
op(x, foldr1(op, y :| xs))
|
99
|
+
|
100
|
+
def scanl1(op, z, xs):
|
101
|
+
def go(x, continue, acc):
|
102
|
+
def next: op(acc, x)
|
103
|
+
|
104
|
+
next :| continue(next)
|
105
|
+
|
106
|
+
foldr(go, const([]), xs, z)
|
107
|
+
|
108
|
+
def scanl(op, z, xs):
|
109
|
+
z :| scanl1(op, z, xs)
|
110
|
+
|
111
|
+
def map(f, []): []
|
112
|
+
def map(f, x :| xs): f(x) :| map(f, xs)
|
113
|
+
|
114
|
+
def append(([], ys)): ys
|
115
|
+
def append((x :| xs, ys)):
|
116
|
+
x :| append((xs, ys))
|
117
|
+
|
118
|
+
def concat2([], ys): ys
|
119
|
+
def concat2(x :| xs, ys):
|
120
|
+
x :| concat2(xs, ys)
|
121
|
+
|
122
|
+
def concat: foldl(concat2, [])
|
123
|
+
|
124
|
+
def concatMap(f, xs): concat(map(f, xs))
|
125
|
+
|
126
|
+
def intersperse([], _): []
|
127
|
+
def intersperse([x], _): [x]
|
128
|
+
def intersperse(x :| y :| ys, sep):
|
129
|
+
x :| sep :| intersperse(y :| ys, sep)
|
130
|
+
|
131
|
+
def iterate(n, f, z):
|
132
|
+
if n == 0: []
|
133
|
+
else:
|
134
|
+
z :| map(f, iterate(n - 1, f, z))
|
135
|
+
|
136
|
+
def sum: foldr((+), 0)
|
137
|
+
|
138
|
+
def last([x]): x
|
139
|
+
def last(x :| y :| ys): last(y :| ys)
|
140
|
+
|
141
|
+
def length([]): 0
|
142
|
+
def length(_ :| xs): 1 + length(xs)
|
143
|
+
|
144
|
+
def reverse([]): []
|
145
|
+
def reverse(x :| xs):
|
146
|
+
append((reverse(xs), [x]))
|
147
|
+
|
148
|
+
def repeat: flip(iterate, id)
|
149
|
+
|
150
|
+
def take(n, xs):
|
151
|
+
if n <= 0: []
|
152
|
+
else:
|
153
|
+
match xs:
|
154
|
+
case []: []
|
155
|
+
case x :| xs:
|
156
|
+
x :| take(n - 1, xs)
|
157
|
+
|
158
|
+
def drop(n, xs):
|
159
|
+
if n <= 0: xs
|
160
|
+
else:
|
161
|
+
match xs:
|
162
|
+
case []: []
|
163
|
+
case _ :| xs: drop(n - 1, xs)
|
164
|
+
|
165
|
+
def lastN(n, xs):
|
166
|
+
foldl(compose(const, drop(1)), xs, drop(n, xs))
|
167
|
+
|
168
|
+
def nth(n, x :| xs):
|
169
|
+
if n == 0: x
|
170
|
+
else: nth(n - 1, xs)
|
171
|
+
|
172
|
+
def nth2(i, j, xss):
|
173
|
+
nth(j - 1, nth(i - 1, xss))
|
174
|
+
|
175
|
+
def lookup(k, []):
|
176
|
+
error("Key not found in map")
|
177
|
+
def lookup(k, (k_, v) :| kvs):
|
178
|
+
if k == k_: v
|
179
|
+
else: lookup(k, kvs)
|
180
|
+
|
181
|
+
def max(n, m):
|
182
|
+
if n > m: n
|
183
|
+
else: m
|
184
|
+
|
185
|
+
def min(n, m):
|
186
|
+
if n < m: n
|
187
|
+
else: m
|
188
|
+
|
189
|
+
def maximum: foldr1(max)
|
190
|
+
|
191
|
+
def minimum: foldr1(min)
|
192
|
+
|
193
|
+
def unzip([]): ([], [])
|
194
|
+
def unzip((x, y) :| zs):
|
195
|
+
def (xs, ys): unzip(zs)
|
196
|
+
|
197
|
+
(x :| xs, y :| ys)
|
198
|
+
|
199
|
+
def zipWith(op, [], ys): []
|
200
|
+
def zipWith(op, x :| xs, []): []
|
201
|
+
def zipWith(op, x :| xs, y :| ys):
|
202
|
+
op(x, y) :| zipWith(op, xs, ys)
|
203
|
+
|
204
|
+
def zip: zipWith(curry(id))
|
205
|
+
|
206
|
+
def enumFromTo(n, m):
|
207
|
+
if n <= m: n :| [n + 1 .. m]
|
208
|
+
else: []
|
209
|
+
|
210
|
+
def range((m1, n1), (m2, n2)):
|
211
|
+
[(i1, i2) for i1 in [m1 .. m2] for i2 in [n1 .. n2]]
|
212
|
+
|
213
|
+
def abs(x, y):
|
214
|
+
if x - y < 0: negate(x - y)
|
215
|
+
else: x - y
|
216
|
+
|
217
|
+
def nub(xs):
|
218
|
+
def nub_([], _): []
|
219
|
+
def nub_(x :| xs, ys):
|
220
|
+
if x |elem| ys: nub_(xs, ys)
|
221
|
+
else:
|
222
|
+
x :| nub_(xs, x :| ys)
|
223
|
+
|
224
|
+
nub_(xs, [])
|
225
|
+
|
226
|
+
def slice(begin, end, xs):
|
227
|
+
take(end - begin, drop(begin, xs))
|
228
|
+
|
229
|
+
def splitOn(p, data):
|
230
|
+
def go(fls, trs, []):
|
231
|
+
(reverse(fls), reverse(trs))
|
232
|
+
def go(fls, trs, x :| xs):
|
233
|
+
if p(x):
|
234
|
+
go(fls, x :| trs, xs)
|
235
|
+
else:
|
236
|
+
go(x :| fls, trs, xs)
|
237
|
+
|
238
|
+
go([], [], data)
|