Skip to content

Commit a9f9bba

Browse files
authored
fix: use enumerate() (#2)
1 parent 07f77dd commit a9f9bba

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

algo.typ

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
sorted-elems += whitespaces
8787
sorted-elems
8888
}
89-
89+
9090
// concatenate consecutive non-whitespace elements
9191
// i.e. just combine everything that definitely aren't
9292
// on separate lines
@@ -98,13 +98,13 @@
9898
if (
9999
child == [ ]
100100
or child == linebreak()
101-
or child == parbreak()
101+
or child == parbreak()
102102
){
103103
if temp != [] {
104104
joined-children.push(temp)
105105
temp = []
106106
}
107-
107+
108108
joined-children.push(child)
109109
} else {
110110
temp += child
@@ -145,16 +145,16 @@
145145
let joined-lines = ()
146146
let line-parts = []
147147
let num-linebreaks = 0
148-
149-
for i, line in lines-and-breaks {
148+
149+
for (i, line) in lines-and-breaks.enumerate() {
150150
if line == linebreak() {
151151
if line-parts != [] {
152152
joined-lines.push(line-parts)
153153
line-parts = []
154154
}
155-
155+
156156
num-linebreaks += 1
157-
157+
158158
if num-linebreaks > 1 {
159159
joined-lines.push([])
160160
}
@@ -163,19 +163,19 @@
163163
num-linebreaks = 0
164164
}
165165
}
166-
166+
167167
if line-parts != [] {
168168
joined-lines.push(line-parts)
169169
}
170170

171171
joined-lines
172172
}
173173
)
174-
174+
175175
let rows = ()
176176

177177
// build table input (with line numbers if specified)
178-
for i, line in display-lines {
178+
for (i, line) in display-lines.enumerate() {
179179
let formatted-line = {
180180
counter("_algo-indent").display(n =>
181181
pad(
@@ -184,15 +184,15 @@
184184
)
185185
)
186186
}
187-
187+
188188
if line-numbers {
189189
let line-number = i + 1
190190
rows.push([#line-number])
191191
}
192192

193193
rows.push(formatted-line)
194194
}
195-
195+
196196
align(center, block(
197197
width: auto,
198198
height: auto,
@@ -204,38 +204,38 @@
204204
)[
205205
#let algo-header = {
206206
set align(left)
207-
207+
208208
if title != none {
209209
set text(1.1em)
210-
210+
211211
if type(title) == "string" {
212212
underline(smallcaps(title))
213213
} else {
214214
title
215215
}
216-
216+
217217
if parameters.len() == 0 {
218218
$()$
219219
}
220220
}
221-
221+
222222
if parameters != () {
223223
set text(1.1em)
224-
224+
225225
$($
226-
227-
for i, param in parameters {
226+
227+
for (i, param) in parameters.enumerate() {
228228
if type(param) == "string" {
229229
math.italic(param)
230230
} else {
231231
param
232232
}
233-
233+
234234
if i < parameters.len() - 1 {
235235
[, ]
236236
}
237237
}
238-
238+
239239
$)$
240240
}
241241

@@ -246,7 +246,7 @@
246246

247247
#algo-header
248248
#v(weak: true, row-gutter)
249-
249+
250250
#align(left, table(
251251
columns: if line-numbers {2} else {1},
252252
column-gutter: column-gutter,
@@ -289,20 +289,20 @@
289289
set par(justify: false)
290290
let content = ()
291291
let i = 1
292-
292+
293293
for item in body.children {
294294
if item.func() == raw {
295295
for line in item.text.split("\n") {
296296
if line-numbers {
297297
content.push(str(i))
298298
}
299-
299+
300300
content.push(raw(line, lang: item.lang))
301301
i += 1
302302
}
303303
}
304304
}
305-
305+
306306
align(center, block(
307307
stroke: stroke,
308308
inset: inset,

0 commit comments

Comments
 (0)