Skip to content

Commit cd238b8

Browse files
committed
fix: coding style
1 parent fc8e2e9 commit cd238b8

20 files changed

+100
-204
lines changed

Events.ark

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@
4848
(list:forEach _listeners (fun (element)
4949
(if (= typ (@ element 0)) {
5050
((@ element 1) val)
51-
(set found true)
52-
})))
53-
found
54-
}))
51+
(set found true)})))
52+
found }))
5553

5654
# @brief Emits an event with no value
5755
# @param typ the type of the emitted event
@@ -75,8 +73,7 @@
7573
(list:filter _listeners (fun (element) (!= typ (@ element 0)))))
7674
(let deleted (!= newlist _listeners))
7775
(set _listeners newlist)
78-
deleted
79-
}))
76+
deleted }))
8077

8178
(fun (
8279
# listeners
@@ -89,6 +86,5 @@
8986
&on
9087
&emit
9188
&emitWith
92-
&removeListenersOfType
93-
) ())
94-
}))
89+
&removeListenersOfType)
90+
() )}))

Lazy.ark

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@
1717
(if (not _has_been_called)
1818
{
1919
(set _has_been_called true)
20-
(set _memorized_value (f))
21-
})
22-
_memorized_value
23-
})
24-
}))
20+
(set _memorized_value (f))})
21+
_memorized_value })}))

List.ark

Lines changed: 34 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
(while (< _index (len _L)) {
1616
(mut _element (@ _L _index))
1717
(_func _element)
18-
(set _index (+ 1 _index))
19-
})
20-
}))
18+
(set _index (+ 1 _index))})}))
2119

2220
# @brief Iterate over a given list and multiply all the elements with the others.
2321
# @param _L the list to iterate over
@@ -33,10 +31,8 @@
3331
(mut _output 1)
3432
(while (< _index (len _L)) {
3533
(set _output (* _output (@ _L _index)))
36-
(set _index (+ 1 _index))
37-
})
38-
_output
39-
}))
34+
(set _index (+ 1 _index))})
35+
_output }))
4036

4137
# @brief Iterate over a given list and sum all the elements.
4238
# @param _L the list to iterate over
@@ -52,10 +48,8 @@
5248
(mut _output 0)
5349
(while (< _index (len _L)) {
5450
(set _output (+ _output (@ _L _index)))
55-
(set _index (+ 1 _index))
56-
})
57-
_output
58-
}))
51+
(set _index (+ 1 _index))})
52+
_output }))
5953

6054
(import "Math.ark") # needed for math:min, math:max
6155

@@ -78,10 +72,8 @@
7872
(mut _output [])
7973
(while (< _index (len _L)) {
8074
(set _output (append _output (@ _L _index)))
81-
(set _index (+ 1 _index))
82-
})
83-
_output
84-
})))
75+
(set _index (+ 1 _index))})
76+
_output })))
8577

8678
# @brief Drop the first elements of a list, while they match a given predicate
8779
# @param _L the list to work on
@@ -101,10 +93,8 @@
10193

10294
(while (< _index (len _L)) {
10395
(set _output (append _output (@ _L _index)))
104-
(set _index (+ 1 _index))
105-
})))
106-
_output
107-
}))
96+
(set _index (+ 1 _index))})))
97+
_output }))
10898

10999
# @brief Keep elements in a given list if they follow a predicate
110100
# @param _L the list to work on
@@ -121,10 +111,8 @@
121111
(while (< _index (len _L)) {
122112
(if (_f (@ _L _index))
123113
(set _output (append _output (@ _L _index))))
124-
(set _index (+ 1 _index))
125-
})
126-
_output
127-
}))
114+
(set _index (+ 1 _index))})
115+
_output }))
128116

129117
# @brief Apply a given function to each element of a list
130118
# @param _L the list to work on
@@ -139,10 +127,8 @@
139127
(mut _output [])
140128
(while (< _index (len _L)) {
141129
(set _output (append _output (_f (@ _L _index))))
142-
(set _index (+ 1 _index))
143-
})
144-
_output
145-
}))
130+
(set _index (+ 1 _index))})
131+
_output }))
146132

147133
# @brief Apply a function to the elements of a list to reduce it
148134
# @param _L the list to work on
@@ -158,10 +144,8 @@
158144
(mut _output (@ _L 0))
159145
(while (< _index (len _L)) {
160146
(set _output (_f _output (@ _L _index)))
161-
(set _index (+ 1 _index))
162-
})
163-
_output
164-
}))
147+
(set _index (+ 1 _index))})
148+
_output }))
165149

166150
# @brief Flatten a list
167151
# @param _L the list to work on
@@ -179,10 +163,8 @@
179163
(set _output (if (= "List" (type _sub))
180164
(concat _output _sub)
181165
(append _output _sub)))
182-
(set _index (+ 1 _index))
183-
})
184-
_output
185-
}))
166+
(set _index (+ 1 _index))})
167+
_output }))
186168

187169
# @brief Apply a given function to each element of a list and then flatten it
188170
# @param _L the list to work on
@@ -201,10 +183,8 @@
201183
(set _output (if (= "List" (type _res))
202184
(concat _output _res)
203185
(append _output _res)))
204-
(set _index (+ 1 _index))
205-
})
206-
_output
207-
}))
186+
(set _index (+ 1 _index))})
187+
_output }))
208188

209189
# @brief Take the first n elements of
210190
# @param _L the list to work on
@@ -221,10 +201,8 @@
221201

222202
(while (< _index _n) {
223203
(set _output (append _output (@ _L _index)))
224-
(set _index (+ 1 _index))
225-
})
226-
_output
227-
}))
204+
(set _index (+ 1 _index))})
205+
_output }))
228206

229207
# @brief Take the first n elements of a list, given a predicate
230208
# @param _L the list to work on
@@ -242,13 +220,9 @@
242220
(if (_f (@ _L _index))
243221
{
244222
(set _output (append _output (@ _L _index)))
245-
(set _index (+ 1 _index))
246-
}
247-
(set continue false)
248-
)
249-
)
250-
_output
251-
}))
223+
(set _index (+ 1 _index))}
224+
(set continue false)))
225+
_output }))
252226

253227
# @brief Unzip a list of [[a b] [c d]...] into [[a c ...] [b d ...]]
254228
# @param _L the list to work on
@@ -267,10 +241,8 @@
267241
(mut current (@ _L _index))
268242
(set _list1 (append _list1 (@ current 0)))
269243
(set _list2 (append _list2 (@ current 1)))
270-
(set _index (+ 1 _index))
271-
})
272-
[_list1 _list2]
273-
}))
244+
(set _index (+ 1 _index))})
245+
[_list1 _list2] }))
274246

275247
# @brief Zip two lists into one: [1 2 3 4] and [5 6 7 8] will give [[1 5] [2 6] [3 7] [4 8]]
276248
# @param _a the first list to work on
@@ -288,10 +260,8 @@
288260
(mut _index 0)
289261
(while (< _index _m) {
290262
(set _c (append _c [(@ _a _index) (@ _b _index)]))
291-
(set _index (+ 1 _index))
292-
})
293-
_c
294-
}))
263+
(set _index (+ 1 _index))})
264+
_c }))
295265

296266
# @brief Fold a given list, starting from the left side
297267
# @param _L the list to work on
@@ -308,10 +278,8 @@
308278
(mut _val _init)
309279
(while (< _index (len _L)) {
310280
(set _val (_f _val (@ _L _index)))
311-
(set _index (+ 1 _index))
312-
})
313-
_val
314-
}))
281+
(set _index (+ 1 _index))})
282+
_val }))
315283

316284
# @brief Check if a condition is verified for all elements of a list
317285
# @param _L the list to work on
@@ -328,10 +296,8 @@
328296
(while (and _verified (< _index (len _L))) {
329297
(if (not (_f (@ _L _index)))
330298
(set _verified false))
331-
(set _index (+ 1 _index))
332-
})
333-
_verified
334-
}))
299+
(set _index (+ 1 _index))})
300+
_verified }))
335301

336302
# @brief Check if a condition if verified for one or more elements of a list
337303
# @param _L the list to work on
@@ -348,7 +314,5 @@
348314
(while (and (not _verified) (< _index (len _L))) {
349315
(if (_f (@ _L _index))
350316
(set _verified true))
351-
(set _index (+ 1 _index))
352-
})
353-
_verified
354-
}))
317+
(set _index (+ 1 _index))})
318+
_verified }))

Macros.ark

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
!{-> (arg fn1 ...fn) {
22
!{if (> (len fn) 0)
33
(-> (fn1 arg) ...fn)
4-
(fn1 arg)
5-
}
6-
}}
4+
(fn1 arg)}}}
75

86
# internal, do not use
97
!{__suffix-dup (sym x) {
108
!{if (> x 1)
11-
(__suffix-dup sym (- x 1))
12-
}
13-
(symcat sym x)
14-
}}
9+
(__suffix-dup sym (- x 1))}
10+
(symcat sym x)}}
1511

1612
!{partial (func ...defargs) {
1713
!{bloc (__suffix-dup a (- (argcount func) (len defargs)))}
1814
(fun (bloc) (func ...defargs bloc))
19-
!{undef bloc}
20-
}}
15+
!{undef bloc}}}

Math.ark

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
(while (and (<= i top) (!= top n)) {
7373
(if (= (mod n i) 0)
7474
(set divisors (append divisors i)))
75-
(set i (+ i 1))
76-
})
75+
(set i (+ i 1))})
7776
(append divisors n)}))
7877

7978
# @brief Returns the logarithm base n of a number
@@ -193,5 +192,4 @@
193192
(let _conj (math:complex-conjugate _c1))
194193
(let _top (math:complex-mul _c0 _conj))
195194
(let _denom (+ (* _c1.real _c1.real) (* _c1.imag _c1.imag)))
196-
(math:complex (/ _top.real _denom) (/ _top.imag _denom))
197-
}))
195+
(math:complex (/ _top.real _denom) (/ _top.imag _denom))}))

Range.ark

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
(mut a_ i)
2020
(while (< a_ _b) {
2121
(set _output (append _output a_))
22-
(set a_ (+ 1 a_))
23-
})
24-
_output
25-
}))
22+
(set a_ (+ 1 a_))})
23+
_output }))
2624

2725
(let _a i)
2826
(let reset (fun () (set i _a)))
@@ -31,10 +29,7 @@
3129
(if (< i _b)
3230
{
3331
(set i (+ i 1))
34-
(- i 1)
35-
})
36-
})
37-
}))
32+
(- i 1)})})}))
3833

3934
# @brief Run a function on each element of the range
4035
# @param _r the range object
@@ -49,10 +44,8 @@
4944
(mut _val (_r))
5045
(while (not (nil? _val)) {
5146
(_f _val)
52-
(set _val (_r))
53-
})
54-
(_r.reset)
55-
}))
47+
(set _val (_r))})
48+
(_r.reset)}))
5649

5750
# @brief Create a list based on a range and a filter function
5851
# @param _range the range object
@@ -68,12 +61,9 @@
6861
(mut _output [])
6962
(while (not (nil? _value)) {
7063
(if (_fun _value) (set _output (append _output _value)))
71-
(set _value (_range))
72-
})
64+
(set _value (_range))})
7365
(_range.reset)
74-
75-
_output
76-
}))
66+
_output }))
7767

7868
# @brief Create a list based on a range and a function to apply to each elements
7969
# @param _range the range object
@@ -89,12 +79,9 @@
8979
(mut _output [])
9080
(while (not (nil? _value)) {
9181
(set _output (append _output (_fun _value)))
92-
(set _value (_range))
93-
})
82+
(set _value (_range))})
9483
(_range.reset)
95-
96-
_output
97-
}))
84+
_output }))
9885

9986
# @brief Create a reduced list based on a range and a reduction function
10087
# @param _range the range object
@@ -110,8 +97,6 @@
11097
(mut _last (_range))
11198
(while (not (nil? _last)) {
11299
(set _output (_fun _output _last))
113-
(set _last (_range))
114-
})
100+
(set _last (_range))})
115101
(_range.reset)
116-
_output
117-
}))
102+
_output }))

0 commit comments

Comments
 (0)