@explorable-viz/fluid 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.spago/{argonaut-codecs/v9.0.0 → affjax-node/v1.0.0}/.editorconfig +1 -1
- package/.spago/affjax-node/v1.0.0/.eslintrc.json +30 -0
- package/.spago/affjax-node/v1.0.0/.gitignore +13 -0
- package/.spago/pathy/v9.0.0/.editorconfig +13 -0
- package/dist/fluid/fluid/dataset/methane-emissions.fld +123 -0
- package/dist/fluid/fluid/dataset/mini-non-renewables.fld +3 -0
- package/dist/fluid/fluid/dataset/mini-renewables.fld +6 -0
- package/dist/fluid/fluid/dataset/non-renewables.fld +67 -0
- package/dist/fluid/fluid/dataset/renewables-new.fld +301 -0
- package/dist/fluid/fluid/dataset/renewables-restricted.fld +139 -0
- package/dist/fluid/fluid/dataset/renewables.fld +100 -0
- package/dist/fluid/fluid/example/arithmetic.fld +1 -0
- package/dist/fluid/fluid/example/array.fld +2 -0
- package/dist/fluid/fluid/example/compose.fld +2 -0
- package/dist/fluid/fluid/example/desugar/list-comp-1.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-10.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-2.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-3.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-4.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-5.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-6.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-7.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-8.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-comp-9.fld +1 -0
- package/dist/fluid/fluid/example/desugar/list-enum.fld +1 -0
- package/dist/fluid/fluid/example/dict-list-comp.fld +1 -0
- package/dist/fluid/fluid/example/dicts.fld +10 -0
- package/dist/fluid/fluid/example/div-mod-quot-rem.fld +4 -0
- package/dist/fluid/fluid/example/factorial.fld +6 -0
- package/dist/fluid/fluid/example/filter.fld +1 -0
- package/dist/fluid/fluid/example/first-class-constr.fld +1 -0
- package/dist/fluid/fluid/example/flatten.fld +12 -0
- package/dist/fluid/fluid/example/foldr-sumSquares.fld +1 -0
- package/dist/fluid/fluid/example/graphics/background.fld +7 -0
- package/dist/fluid/fluid/example/graphics/grouped-bar-chart.fld +9 -0
- package/dist/fluid/fluid/example/graphics/line-chart.fld +13 -0
- package/dist/fluid/fluid/example/graphics/stacked-bar-chart.fld +3 -0
- package/dist/fluid/fluid/example/include-input-into-output.fld +1 -0
- package/dist/fluid/fluid/example/length.fld +1 -0
- package/dist/fluid/fluid/example/lexicalScoping.fld +3 -0
- package/dist/fluid/fluid/example/lib/some-constants.fld +1 -0
- package/dist/fluid/fluid/example/linked-inputs/energyscatter.fld +24 -0
- package/dist/fluid/fluid/example/linked-inputs/mini-energyscatter.fld +30 -0
- package/dist/fluid/fluid/example/linked-outputs/convolution-data.fld +5 -0
- package/dist/fluid/fluid/example/linked-outputs/convolution.fld +12 -0
- package/dist/fluid/fluid/example/linked-outputs/line-chart.fld +15 -0
- package/dist/fluid/fluid/example/linked-outputs/moving-average.fld +19 -0
- package/dist/fluid/fluid/example/linked-outputs/pairs-data.fld +1 -0
- package/dist/fluid/fluid/example/linked-outputs/pairs.fld +2 -0
- package/dist/fluid/fluid/example/lookup.fld +15 -0
- package/dist/fluid/fluid/example/map.fld +1 -0
- package/dist/fluid/fluid/example/mergeSort.fld +22 -0
- package/dist/fluid/fluid/example/normalise.fld +3 -0
- package/dist/fluid/fluid/example/nub.fld +1 -0
- package/dist/fluid/fluid/example/pattern-match.fld +12 -0
- package/dist/fluid/fluid/example/percent.fld +1 -0
- package/dist/fluid/fluid/example/plot/methane.fld +14 -0
- package/dist/fluid/fluid/example/plot/non-renewables.fld +22 -0
- package/dist/fluid/fluid/example/range.fld +4 -0
- package/dist/fluid/fluid/example/record-lookup.fld +3 -0
- package/dist/fluid/fluid/example/records.expect.fld +0 -0
- package/dist/fluid/fluid/example/records.fld +11 -0
- package/dist/fluid/fluid/example/reverse.fld +1 -0
- package/dist/fluid/fluid/example/scratchpad.fld +6 -0
- package/dist/fluid/fluid/example/slicing/add.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/add.fld +1 -0
- package/dist/fluid/fluid/example/slicing/array/array.expect.fld +2 -0
- package/dist/fluid/fluid/example/slicing/array/array.fld +4 -0
- package/dist/fluid/fluid/example/slicing/array/dims.expect.fld +3 -0
- package/dist/fluid/fluid/example/slicing/array/dims.fld +3 -0
- package/dist/fluid/fluid/example/slicing/array/lookup.expect.fld +3 -0
- package/dist/fluid/fluid/example/slicing/array/lookup.fld +5 -0
- package/dist/fluid/fluid/example/slicing/array/renewables.fld +100 -0
- package/dist/fluid/fluid/example/slicing/convolution/edgeDetect.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/edgeDetect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/emboss-wrap.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/emboss.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/emboss.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/filter/edge-detect.fld +5 -0
- package/dist/fluid/fluid/example/slicing/convolution/filter/emboss.fld +5 -0
- package/dist/fluid/fluid/example/slicing/convolution/filter/gaussian.fld +5 -0
- package/dist/fluid/fluid/example/slicing/convolution/gaussian.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/gaussian.fld +1 -0
- package/dist/fluid/fluid/example/slicing/convolution/test-image.fld +7 -0
- package/dist/fluid/fluid/example/slicing/dict/create.expect.fld +2 -0
- package/dist/fluid/fluid/example/slicing/dict/create.fld +1 -0
- package/dist/fluid/fluid/example/slicing/dict/difference.expect.fld +4 -0
- package/dist/fluid/fluid/example/slicing/dict/difference.fld +3 -0
- package/dist/fluid/fluid/example/slicing/dict/disjointUnion.expect.fld +2 -0
- package/dist/fluid/fluid/example/slicing/dict/disjointUnion.fld +1 -0
- package/dist/fluid/fluid/example/slicing/dict/foldl.expect.fld +3 -0
- package/dist/fluid/fluid/example/slicing/dict/foldl.fld +1 -0
- package/dist/fluid/fluid/example/slicing/dict/get.expect.fld +5 -0
- package/dist/fluid/fluid/example/slicing/dict/get.fld +3 -0
- package/dist/fluid/fluid/example/slicing/dict/intersectionWith.expect.fld +5 -0
- package/dist/fluid/fluid/example/slicing/dict/intersectionWith.fld +4 -0
- package/dist/fluid/fluid/example/slicing/dict/map.expect.fld +8 -0
- package/dist/fluid/fluid/example/slicing/dict/map.fld +5 -0
- package/dist/fluid/fluid/example/slicing/dict/match.expect.fld +6 -0
- package/dist/fluid/fluid/example/slicing/dict/match.fld +5 -0
- package/dist/fluid/fluid/example/slicing/divide.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/divide.fld +1 -0
- package/dist/fluid/fluid/example/slicing/dtw/average-series.expect.fld +8 -0
- package/dist/fluid/fluid/example/slicing/dtw/average-series.fld +8 -0
- package/dist/fluid/fluid/example/slicing/dtw/compute-dtw.expect.fld +6 -0
- package/dist/fluid/fluid/example/slicing/dtw/compute-dtw.fld +6 -0
- package/dist/fluid/fluid/example/slicing/explained.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/explained.fld +1 -0
- package/dist/fluid/fluid/example/slicing/filter.expect.fld +4 -0
- package/dist/fluid/fluid/example/slicing/filter.fld +6 -0
- package/dist/fluid/fluid/example/slicing/intersperse-1.expect.fld +4 -0
- package/dist/fluid/fluid/example/slicing/intersperse-2.expect.fld +4 -0
- package/dist/fluid/fluid/example/slicing/intersperse.fld +5 -0
- package/dist/fluid/fluid/example/slicing/length.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/length.fld +1 -0
- package/dist/fluid/fluid/example/slicing/linked-outputs/bar-chart-line-chart.expect.fld +0 -0
- package/dist/fluid/fluid/example/slicing/linked-outputs/bar-chart-line-chart.fld +29 -0
- package/dist/fluid/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.expect.fld +0 -0
- package/dist/fluid/fluid/example/slicing/linked-outputs/stacked-bar-scatter-plot.fld +39 -0
- package/dist/fluid/fluid/example/slicing/list-comp-1.expect.fld +6 -0
- package/dist/fluid/fluid/example/slicing/list-comp-2.expect.fld +6 -0
- package/dist/fluid/fluid/example/slicing/list-comp.fld +8 -0
- package/dist/fluid/fluid/example/slicing/lookup.expect.fld +6 -0
- package/dist/fluid/fluid/example/slicing/lookup.fld +14 -0
- package/dist/fluid/fluid/example/slicing/map.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/map.fld +1 -0
- package/dist/fluid/fluid/example/slicing/matrix-update.expect.fld +5 -0
- package/dist/fluid/fluid/example/slicing/matrix-update.fld +10 -0
- package/dist/fluid/fluid/example/slicing/multiply.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/multiply.fld +1 -0
- package/dist/fluid/fluid/example/slicing/nth.expect.fld +1 -0
- package/dist/fluid/fluid/example/slicing/nth.fld +1 -0
- package/dist/fluid/fluid/example/slicing/output-not-source.expect.fld +2 -0
- package/dist/fluid/fluid/example/slicing/output-not-source.fld +1 -0
- package/dist/fluid/fluid/example/slicing/section-5-example-1.expect.fld +10 -0
- package/dist/fluid/fluid/example/slicing/section-5-example-2.expect.fld +10 -0
- package/dist/fluid/fluid/example/slicing/section-5-example-3.expect.fld +10 -0
- package/dist/fluid/fluid/example/slicing/section-5-example.fld +14 -0
- package/dist/fluid/fluid/example/slicing/zeros-1.expect.fld +3 -0
- package/dist/fluid/fluid/example/slicing/zeros-2.expect.fld +3 -0
- package/dist/fluid/fluid/example/slicing/zeros.fld +4 -0
- package/dist/fluid/fluid/example/slicing/zipWith-1.expect.fld +4 -0
- package/dist/fluid/fluid/example/slicing/zipWith.fld +4 -0
- package/dist/fluid/fluid/example/text-viz/explainable-table.fld +7 -0
- package/dist/fluid/fluid/example/text-viz/fake-probabilities.fld +3 -0
- package/dist/fluid/fluid/example/text-viz/figure-spm-4.fld +42 -0
- package/dist/fluid/fluid/example/text-viz/left-barchart-table.fld +5 -0
- package/dist/fluid/fluid/example/text-viz/likelihoods.fld +9 -0
- package/dist/fluid/fluid/example/text-viz/right-barchart-table.fld +5 -0
- package/dist/fluid/fluid/example/text-viz/table-spm-1.fld +30 -0
- package/dist/fluid/fluid/lib/convolution.fld +16 -0
- package/dist/fluid/fluid/lib/dtw.fld +47 -0
- package/dist/fluid/fluid/lib/fnum.fld +22 -0
- package/dist/fluid/fluid/lib/graphics.fld +221 -0
- package/dist/fluid/fluid/lib/prelude.fld +266 -0
- package/dist/fluid/fluid/lib/text-viz.fld +18 -0
- package/dist/fluid/fluid.mjs +28285 -0
- package/package.json +1 -1
- package/.spago/node-process/v11.0.0/.eslintrc.json +0 -29
- package/.spago/node-process/v11.0.0/.gitignore +0 -8
- package/.spago/node-process/v11.1.0/.eslintrc.json +0 -29
- package/.spago/node-process/v11.1.0/.gitignore +0 -8
- package/.spago/node-process/v11.2.0/.eslintrc.json +0 -29
- package/.spago/node-process/v11.2.0/.gitignore +0 -8
- package/.spago/optparse/v6.0.0/.gitignore +0 -8
- package/.spago/optparse/v6.0.0/.npmrc +0 -1
- /package/.spago/{argonaut-codecs → pathy}/v9.0.0/.gitignore +0 -0
- /package/.spago/{argonaut-codecs → pathy}/v9.0.0/.tidyrc.json +0 -0
@@ -0,0 +1,266 @@
|
|
1
|
+
-- "Num" throughout means (Int + Float).
|
2
|
+
|
3
|
+
-- Bool -> Bool
|
4
|
+
let and False y = False;
|
5
|
+
and True y = y;
|
6
|
+
|
7
|
+
-- Bool -> Bool
|
8
|
+
let or True y = True;
|
9
|
+
or False y = y;
|
10
|
+
|
11
|
+
-- Bool -> Bool
|
12
|
+
let not True = False;
|
13
|
+
not False = True;
|
14
|
+
|
15
|
+
-- Int -> Int -> Ordering
|
16
|
+
let compare x y =
|
17
|
+
if x > y
|
18
|
+
then GT
|
19
|
+
else if x < y
|
20
|
+
then LT
|
21
|
+
else EQ;
|
22
|
+
|
23
|
+
-- Num -> Num
|
24
|
+
let negate = (-) 0;
|
25
|
+
|
26
|
+
-- Log of x in base y.
|
27
|
+
-- Float -> Float -> Float
|
28
|
+
let logBase x y = log y / log x;
|
29
|
+
|
30
|
+
-- Float -> Float -> Float
|
31
|
+
let ceilingToNearest n m =
|
32
|
+
ceiling (n / m) * m;
|
33
|
+
|
34
|
+
-- (b -> c) -> (a -> b) -> a -> c
|
35
|
+
-- Want infix <<<
|
36
|
+
let compose f g x = f (g x);
|
37
|
+
|
38
|
+
-- ((a, b) -> c) -> a -> b -> c
|
39
|
+
let curry f x y = f (x, y);
|
40
|
+
|
41
|
+
-- (a -> b -> c) -> (a, b) -> c
|
42
|
+
let uncurry f (x, y) = f x y;
|
43
|
+
|
44
|
+
-- a -> b -> a
|
45
|
+
let const x _ = x;
|
46
|
+
|
47
|
+
-- (a -> b) -> (a, c) -> (b, c)
|
48
|
+
let first f (a, c) = (f a, c);
|
49
|
+
|
50
|
+
-- (a, b) -> b
|
51
|
+
let snd (_, y) = y;
|
52
|
+
|
53
|
+
-- (a -> b) -> (c, a) -> (c, b)
|
54
|
+
let second f (c, a) = (c, f a);
|
55
|
+
|
56
|
+
-- (a -> b -> c) -> b -> a -> c
|
57
|
+
let flip f x y = f y x;
|
58
|
+
|
59
|
+
-- (a, b) -> a
|
60
|
+
let fst (x, _) = x;
|
61
|
+
|
62
|
+
-- a -> a
|
63
|
+
let id x = x;
|
64
|
+
|
65
|
+
-- (a -> b) -> (a -> c) -> a -> (b, c)
|
66
|
+
-- Want infix &&&
|
67
|
+
let prod f g x = (f x, g x);
|
68
|
+
|
69
|
+
-- (a, b) -> (b, a)
|
70
|
+
let swap (a, b) = (b, a);
|
71
|
+
|
72
|
+
-- List a -> a
|
73
|
+
let head [] = error "Can't take head of empty list";
|
74
|
+
head (x : _) = x;
|
75
|
+
|
76
|
+
-- List a -> List a
|
77
|
+
let tail [] = error "Can't take tail of empty list";
|
78
|
+
tail (_ : xs) = xs;
|
79
|
+
|
80
|
+
-- Eq a => a -> List a -> Bool
|
81
|
+
let elem x [] = False;
|
82
|
+
elem x (x' : xs) = (x == x') `or` (elem x xs);
|
83
|
+
|
84
|
+
-- (a -> Bool) -> List a -> Option a
|
85
|
+
let find p [] = error "not found";
|
86
|
+
find p (x : xs) = if p x then Some x else find p xs;
|
87
|
+
|
88
|
+
-- String -> String -> List Dict -> Option Dict
|
89
|
+
let findWithKey fname fval table = find (fun y -> y.[fname] == fval) table;
|
90
|
+
|
91
|
+
let fromSome option = match option as {
|
92
|
+
None -> error "Expected Some!";
|
93
|
+
Some x -> x
|
94
|
+
};
|
95
|
+
|
96
|
+
-- (a -> Bool) -> List a -> List a
|
97
|
+
let filter p [] = [];
|
98
|
+
filter p (x : xs) =
|
99
|
+
let ys = filter p xs in
|
100
|
+
if p x then x : ys else ys;
|
101
|
+
|
102
|
+
-- (a -> Option b) -> List a -> List b
|
103
|
+
let filterMap p [] = [];
|
104
|
+
filterMap p (x : xs) =
|
105
|
+
match p x as {
|
106
|
+
None -> filterMap f xs;
|
107
|
+
Some y -> y : filterMap f xs
|
108
|
+
};
|
109
|
+
|
110
|
+
-- (a -> b -> a) -> a -> List b -> a
|
111
|
+
let foldl op z [] = z;
|
112
|
+
foldl op z (x : xs) = foldl op (op z x) xs;
|
113
|
+
|
114
|
+
-- (a -> b -> a) -> List b -> a
|
115
|
+
let foldl1 op (x : xs) = foldl op x xs;
|
116
|
+
|
117
|
+
-- (a -> b -> b) -> b -> List a -> b
|
118
|
+
let foldr op z [] = z;
|
119
|
+
foldr op z (x : xs) = op x (foldr op z xs);
|
120
|
+
|
121
|
+
-- (a -> b -> b) -> List a -> b
|
122
|
+
let foldr1 op [x] = x;
|
123
|
+
foldr1 op (x : y : xs) = op x (foldr1 op (y : xs));
|
124
|
+
|
125
|
+
-- (a -> b -> a) -> a -> List b -> List a
|
126
|
+
let scanl1 op z xs =
|
127
|
+
let go x continue acc =
|
128
|
+
let next = op acc x in
|
129
|
+
next : continue next in
|
130
|
+
foldr go (const []) xs z;
|
131
|
+
|
132
|
+
-- (a -> b -> a) -> a -> List b -> List a
|
133
|
+
let scanl op z xs =
|
134
|
+
z : scanl1 op z xs;
|
135
|
+
|
136
|
+
-- (a -> b) -> List a -> List b
|
137
|
+
let map f [] = [];
|
138
|
+
map f (x : xs) = f x : map f xs;
|
139
|
+
|
140
|
+
-- (List a, List a) -> List a
|
141
|
+
let append ([], ys) = ys;
|
142
|
+
append (x : xs, ys) = x : append (xs, ys);
|
143
|
+
|
144
|
+
-- List a -> List -> List a
|
145
|
+
-- Want infix ++
|
146
|
+
let concat2 [] ys = ys;
|
147
|
+
concat2 (x : xs) ys = x : concat2 xs ys;
|
148
|
+
|
149
|
+
-- List (List a) -> List a
|
150
|
+
let concat = foldl concat2 [];
|
151
|
+
|
152
|
+
-- (a -> List b) -> List a -> List b
|
153
|
+
let concatMap f xs = concat (map f xs);
|
154
|
+
|
155
|
+
-- List a -> a -> List a
|
156
|
+
let intersperse [] _ = [];
|
157
|
+
intersperse [x] _ = [x];
|
158
|
+
intersperse (x : y : ys) sep = x : sep : intersperse (y : ys) sep;
|
159
|
+
|
160
|
+
-- Int -> (a -> a) -> a -> List a
|
161
|
+
let iterate n f z =
|
162
|
+
if n == 0 then [] else z : map f (iterate (n - 1) f z);
|
163
|
+
|
164
|
+
-- List Int -> Int
|
165
|
+
let sum = foldr (+) 0;
|
166
|
+
|
167
|
+
-- List a -> a
|
168
|
+
let last [x] = x;
|
169
|
+
last (x : y : ys) = last (y : ys);
|
170
|
+
|
171
|
+
-- List a -> Int
|
172
|
+
let length [] = 0;
|
173
|
+
length (_ : xs) = 1 + length xs;
|
174
|
+
|
175
|
+
-- List a -> List a
|
176
|
+
let reverse [] = [];
|
177
|
+
reverse (x : xs) = append (reverse xs, [x]);
|
178
|
+
|
179
|
+
-- Int -> a -> List a
|
180
|
+
let repeat = flip iterate id;
|
181
|
+
|
182
|
+
-- Int -> List a -> List a
|
183
|
+
let take n xs =
|
184
|
+
if n <= 0
|
185
|
+
then []
|
186
|
+
else match xs as {
|
187
|
+
[] -> [];
|
188
|
+
x : xs -> x : take (n - 1) xs
|
189
|
+
};
|
190
|
+
|
191
|
+
-- Int -> List a -> List a
|
192
|
+
let drop n xs =
|
193
|
+
if n <= 0
|
194
|
+
then xs
|
195
|
+
else match xs as {
|
196
|
+
[] -> [];
|
197
|
+
_ : xs -> drop (n - 1) xs
|
198
|
+
};
|
199
|
+
|
200
|
+
-- Int -> List a -> List a
|
201
|
+
let lastN n xs =
|
202
|
+
foldl (compose const (drop 1)) xs (drop n xs);
|
203
|
+
|
204
|
+
-- Expects non-negative integer as first argument and non-empty list as second argument.
|
205
|
+
-- Int -> List a -> a
|
206
|
+
let nth n (x : xs) =
|
207
|
+
if n == 0 then x else nth (n - 1) xs;
|
208
|
+
|
209
|
+
-- Matrix Int -> Int -> Int -> Int
|
210
|
+
let nth2 i j xss =
|
211
|
+
nth (j - 1) (nth (i - 1) xss);
|
212
|
+
|
213
|
+
-- Partial; requires k to be in the map.
|
214
|
+
-- Int -> List (Int, b) -> b
|
215
|
+
let lookup k [] = error "Key not found in map";
|
216
|
+
lookup k ((k', v) : kvs) =
|
217
|
+
if k == k' then v else lookup k kvs;
|
218
|
+
|
219
|
+
-- Int -> Int -> Int
|
220
|
+
let max n m =
|
221
|
+
if n > m then n else m;
|
222
|
+
|
223
|
+
-- Int -> Int -> Int
|
224
|
+
let min n m =
|
225
|
+
if n < m then n else m;
|
226
|
+
|
227
|
+
-- List Int -> Int
|
228
|
+
let maximum = foldr1 max;
|
229
|
+
|
230
|
+
-- List Int -> Int
|
231
|
+
let minimum = foldr1 min;
|
232
|
+
|
233
|
+
-- List (a, b) -> (List a, List b)
|
234
|
+
let unzip [] = ([], []);
|
235
|
+
unzip ((x, y) : zs) =
|
236
|
+
let (xs, ys) = unzip zs in
|
237
|
+
(x : xs, y : ys);
|
238
|
+
|
239
|
+
-- (a -> b -> c) -> List a -> List b -> List c
|
240
|
+
let zipWith op [] ys = [];
|
241
|
+
zipWith op (x : xs) [] = [];
|
242
|
+
zipWith op (x : xs) (y : ys) = op x y : zipWith op xs ys;
|
243
|
+
|
244
|
+
-- List a -> List b -> List (a, b)
|
245
|
+
let zip = zipWith (curry id);
|
246
|
+
|
247
|
+
-- Int -> Int -> List Int
|
248
|
+
let enumFromTo n m =
|
249
|
+
if n <= m then n : [n + 1 .. m] else [];
|
250
|
+
|
251
|
+
let range (m1, n1) (m2, n2) =
|
252
|
+
[ (i1, i2) | i1 <- [m1 .. m2], i2 <- [n1 .. n2] ];
|
253
|
+
|
254
|
+
-- Int -> Int -> Int
|
255
|
+
let abs x y =
|
256
|
+
if x - y < 0 then negate (x - y) else (x - y);
|
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);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
let likelihoodMap table prob = (fromSome (find (fun x -> x.prob <= prob) table)).msg;
|
2
|
+
|
3
|
+
let mkPercent num = (numToStr (num * 100)) ++ "%";
|
4
|
+
|
5
|
+
let leqP n m =
|
6
|
+
if n <= m
|
7
|
+
then "less"
|
8
|
+
else "more";
|
9
|
+
|
10
|
+
let gradedLeqP n m =
|
11
|
+
let ratio = n / m
|
12
|
+
in if ratio <= 1.0
|
13
|
+
then if ratio <=0.5
|
14
|
+
then "much less"
|
15
|
+
else "less"
|
16
|
+
else if ratio >= 2.0
|
17
|
+
then "much more"
|
18
|
+
else "more";
|