@@ -110,12 +110,12 @@ macro evalOnceAs(expAlias, exp: untyped,
110
110
newProc (name = genSym (nskTemplate, $ expAlias), params = [getType (untyped )],
111
111
body = val, procType = nnkTemplateDef))
112
112
113
- proc concat * [T](seqs: varargs [seq [T]]): seq [T] =
113
+ func concat * [T](seqs: varargs [seq [T]]): seq [T] =
114
114
# # Takes several sequences' items and returns them inside a new sequence.
115
115
# # All sequences must be of the same type.
116
116
# #
117
117
# # See also:
118
- # # * `distribute proc <#distribute,seq[T],Positive>`_ for a reverse
118
+ # # * `distribute func <#distribute,seq[T],Positive>`_ for a reverse
119
119
# # operation
120
120
# #
121
121
runnableExamples:
@@ -135,7 +135,7 @@ proc concat*[T](seqs: varargs[seq[T]]): seq[T] =
135
135
result [i] = itm
136
136
inc (i)
137
137
138
- proc count * [T](s: openArray [T], x: T): int =
138
+ func count * [T](s: openArray [T], x: T): int =
139
139
# # Returns the number of occurrences of the item `x` in the container `s`.
140
140
# #
141
141
runnableExamples:
@@ -150,7 +150,7 @@ proc count*[T](s: openArray[T], x: T): int =
150
150
if itm == x:
151
151
inc result
152
152
153
- proc cycle * [T](s: openArray [T], n: Natural ): seq [T] =
153
+ func cycle * [T](s: openArray [T], n: Natural ): seq [T] =
154
154
# # Returns a new sequence with the items of the container `s` repeated
155
155
# # `n` times.
156
156
# # `n` must be a non-negative number (zero or more).
@@ -168,7 +168,7 @@ proc cycle*[T](s: openArray[T], n: Natural): seq[T] =
168
168
result [o] = e
169
169
inc o
170
170
171
- proc repeat * [T](x: T, n: Natural ): seq [T] =
171
+ func repeat * [T](x: T, n: Natural ): seq [T] =
172
172
# # Returns a new sequence with the item `x` repeated `n` times.
173
173
# # `n` must be a non-negative number (zero or more).
174
174
# #
@@ -181,7 +181,7 @@ proc repeat*[T](x: T, n: Natural): seq[T] =
181
181
for i in 0 ..< n:
182
182
result [i] = x
183
183
184
- proc deduplicate * [T](s: openArray [T], isSorted: bool = false ): seq [T] =
184
+ func deduplicate * [T](s: openArray [T], isSorted: bool = false ): seq [T] =
185
185
# # Returns a new sequence without duplicates.
186
186
# #
187
187
# # Setting the optional argument ``isSorted`` to ``true`` (default: false)
@@ -209,7 +209,7 @@ proc deduplicate*[T](s: openArray[T], isSorted: bool = false): seq[T] =
209
209
for itm in items (s):
210
210
if not result .contains (itm): result .add (itm)
211
211
212
- proc minIndex * [T](s: openArray [T]): int {.since : (1 , 1 ).} =
212
+ func minIndex * [T](s: openArray [T]): int {.since : (1 , 1 ).} =
213
213
# # Returns the index of the minimum value of `s`.
214
214
# # ``T`` needs to have a ``<`` operator.
215
215
runnableExamples:
@@ -226,7 +226,7 @@ proc minIndex*[T](s: openArray[T]): int {.since: (1, 1).} =
226
226
for i in 1 .. high (s):
227
227
if s[i] < s[result ]: result = i
228
228
229
- proc maxIndex * [T](s: openArray [T]): int {.since : (1 , 1 ).} =
229
+ func maxIndex * [T](s: openArray [T]): int {.since : (1 , 1 ).} =
230
230
# # Returns the index of the maximum value of `s`.
231
231
# # ``T`` needs to have a ``<`` operator.
232
232
runnableExamples:
@@ -245,7 +245,7 @@ proc maxIndex*[T](s: openArray[T]): int {.since: (1, 1).} =
245
245
246
246
247
247
template zipImpl (s1, s2, retType: untyped ): untyped =
248
- proc zip * [S, T](s1: openArray [S], s2: openArray [T]): retType =
248
+ func zip * [S, T](s1: openArray [S], s2: openArray [T]): retType =
249
249
# # Returns a new sequence with a combination of the two input containers.
250
250
# #
251
251
# # The input containers can be of different types.
@@ -288,7 +288,7 @@ when (NimMajor, NimMinor) <= (1, 0):
288
288
else :
289
289
zipImpl (s1, s2, seq [(S, T)])
290
290
291
- proc unzip * [S, T](s: openArray [(S, T)]): (seq [S], seq [T]) {.since : (1 , 1 ).} =
291
+ func unzip * [S, T](s: openArray [(S, T)]): (seq [S], seq [T]) {.since : (1 , 1 ).} =
292
292
# # Returns a tuple of two sequences split out from a sequence of 2-field tuples.
293
293
runnableExamples:
294
294
let
@@ -303,19 +303,19 @@ proc unzip*[S, T](s: openArray[(S, T)]): (seq[S], seq[T]) {.since: (1, 1).} =
303
303
result [0 ][i] = s[i][0 ]
304
304
result [1 ][i] = s[i][1 ]
305
305
306
- proc distribute * [T](s: seq [T], num: Positive , spread = true ): seq [seq [T]] =
306
+ func distribute * [T](s: seq [T], num: Positive , spread = true ): seq [seq [T]] =
307
307
# # Splits and distributes a sequence `s` into `num` sub-sequences.
308
308
# #
309
309
# # Returns a sequence of `num` sequences. For *some* input values this is the
310
- # # inverse of the `concat <#concat,varargs[seq[T]]>`_ proc .
310
+ # # inverse of the `concat <#concat,varargs[seq[T]]>`_ func .
311
311
# # The input sequence `s` can be empty, which will produce
312
312
# # `num` empty sequences.
313
313
# #
314
314
# # If `spread` is false and the length of `s` is not a multiple of `num`, the
315
- # # proc will max out the first sub-sequence with ``1 + len(s) div num``
315
+ # # func will max out the first sub-sequence with ``1 + len(s) div num``
316
316
# # entries, leaving the remainder of elements to the last sequence.
317
317
# #
318
- # # On the other hand, if `spread` is true, the proc will distribute evenly
318
+ # # On the other hand, if `spread` is true, the func will distribute evenly
319
319
# # the remainder of the division across all sequences, which makes the result
320
320
# # more suited to multithreading where you are passing equal sized work units
321
321
# # to a thread pool and want to maximize core usage.
@@ -360,7 +360,7 @@ proc distribute*[T](s: seq[T], num: Positive, spread = true): seq[seq[T]] =
360
360
result [i].add (s[g])
361
361
first = last
362
362
363
- proc map * [T, S](s: openArray [T], op: proc (x: T): S {.closure .}):
363
+ func map * [T, S](s: openArray [T], op: proc (x: T): S {.closure .}):
364
364
seq [S]{.inline .} =
365
365
# # Returns a new sequence with the results of `op` proc applied to every
366
366
# # item in the container `s`.
@@ -374,7 +374,7 @@ proc map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
374
374
# # See also:
375
375
# # * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
376
376
# # * `mapIt template<#mapIt.t,typed,untyped>`_
377
- # # * `apply proc <#apply,openArray[T],proc(T)_2>`_ for the in-place version
377
+ # # * `apply func <#apply,openArray[T],proc(T)_2>`_ for the in-place version
378
378
# #
379
379
runnableExamples:
380
380
let
@@ -386,7 +386,7 @@ proc map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
386
386
for i in 0 ..< s.len:
387
387
result [i] = op (s[i])
388
388
389
- proc apply * [T](s: var openArray [T], op: proc (x: var T) {.closure .})
389
+ func apply * [T](s: var openArray [T], op: proc (x: var T) {.closure .})
390
390
{.inline .} =
391
391
# # Applies `op` to every item in `s` modifying it directly.
392
392
# #
@@ -397,7 +397,7 @@ proc apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
397
397
# #
398
398
# # See also:
399
399
# # * `applyIt template<#applyIt.t,untyped,untyped>`_
400
- # # * `map proc <#map,openArray[T],proc(T)>`_
400
+ # # * `map func <#map,openArray[T],proc(T)>`_
401
401
# #
402
402
runnableExamples:
403
403
var a = @ [" 1" , " 2" , " 3" , " 4" ]
@@ -406,7 +406,7 @@ proc apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
406
406
407
407
for i in 0 ..< s.len: op (s[i])
408
408
409
- proc apply * [T](s: var openArray [T], op: proc (x: T): T {.closure .})
409
+ func apply * [T](s: var openArray [T], op: proc (x: T): T {.closure .})
410
410
{.inline .} =
411
411
# # Applies `op` to every item in `s` modifying it directly.
412
412
# #
@@ -417,7 +417,7 @@ proc apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
417
417
# #
418
418
# # See also:
419
419
# # * `applyIt template<#applyIt.t,untyped,untyped>`_
420
- # # * `map proc <#map,openArray[T],proc(T)>`_
420
+ # # * `map func <#map,openArray[T],proc(T)>`_
421
421
# #
422
422
runnableExamples:
423
423
var a = @ [" 1" , " 2" , " 3" , " 4" ]
@@ -426,7 +426,7 @@ proc apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
426
426
427
427
for i in 0 ..< s.len: s[i] = op (s[i])
428
428
429
- proc apply * [T](s: openArray [T], op: proc (x: T) {.closure .}) {.inline , since : (1 , 3 ).} =
429
+ func apply * [T](s: openArray [T], op: proc (x: T) {.closure .}) {.inline , since : (1 , 3 ).} =
430
430
# # Same as `apply` but for proc that do not return and do not mutate `s` directly.
431
431
runnableExamples: apply ([0 , 1 , 2 , 3 , 4 ], proc (item: int ) = echo item)
432
432
for i in 0 ..< s.len: op (s[i])
@@ -440,7 +440,7 @@ iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T =
440
440
# #
441
441
# # See also:
442
442
# # * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
443
- # # * `fliter proc <#filter,openArray[T],proc(T)>`_
443
+ # # * `fliter func <#filter,openArray[T],proc(T)>`_
444
444
# # * `filterIt template<#filterIt.t,untyped,untyped>`_
445
445
# #
446
446
runnableExamples:
@@ -454,7 +454,7 @@ iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T =
454
454
if pred (s[i]):
455
455
yield s[i]
456
456
457
- proc filter * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): seq [T]
457
+ func filter * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): seq [T]
458
458
{.inline .} =
459
459
# # Returns a new sequence with all the items of `s` that fulfilled the
460
460
# # predicate `pred` (function that returns a `bool`).
@@ -466,7 +466,7 @@ proc filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
466
466
# # * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
467
467
# # * `filterIt template<#filterIt.t,untyped,untyped>`_
468
468
# # * `filter iterator<#filter.i,openArray[T],proc(T)>`_
469
- # # * `keepIf proc <#keepIf,seq[T],proc(T)>`_ for the in-place version
469
+ # # * `keepIf func <#keepIf,seq[T],proc(T)>`_ for the in-place version
470
470
# #
471
471
runnableExamples:
472
472
let
@@ -481,19 +481,19 @@ proc filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
481
481
if pred (s[i]):
482
482
result .add (s[i])
483
483
484
- proc keepIf * [T](s: var seq [T], pred: proc (x: T): bool {.closure .})
484
+ func keepIf * [T](s: var seq [T], pred: proc (x: T): bool {.closure .})
485
485
{.inline .} =
486
486
# # Keeps the items in the passed sequence `s` if they fulfilled the
487
487
# # predicate `pred` (function that returns a `bool`).
488
488
# #
489
489
# # Note that `s` must be declared as a ``var``.
490
490
# #
491
- # # Similar to the `filter proc <#filter,openArray[T],proc(T)>`_,
491
+ # # Similar to the `filter func <#filter,openArray[T],proc(T)>`_,
492
492
# # but modifies the sequence directly.
493
493
# #
494
494
# # See also:
495
495
# # * `keepItIf template<#keepItIf.t,seq,untyped>`_
496
- # # * `filter proc <#filter,openArray[T],proc(T)>`_
496
+ # # * `filter func <#filter,openArray[T],proc(T)>`_
497
497
# #
498
498
runnableExamples:
499
499
var floats = @ [13.0 , 12.5 , 5.8 , 2.0 , 6.1 , 9.9 , 10.1 ]
@@ -511,7 +511,7 @@ proc keepIf*[T](s: var seq[T], pred: proc(x: T): bool {.closure.})
511
511
inc (pos)
512
512
setLen (s, pos)
513
513
514
- proc delete * [T](s: var seq [T]; first, last: Natural ) =
514
+ func delete * [T](s: var seq [T]; first, last: Natural ) =
515
515
# # Deletes in the items of a sequence `s` at positions ``first..last``
516
516
# # (including both ends of a range).
517
517
# # This modifies `s` itself, it does not return a copy.
@@ -536,7 +536,7 @@ proc delete*[T](s: var seq[T]; first, last: Natural) =
536
536
inc (j)
537
537
setLen (s, newLen)
538
538
539
- proc insert * [T](dest: var seq [T], src: openArray [T], pos = 0 ) =
539
+ func insert * [T](dest: var seq [T], src: openArray [T], pos = 0 ) =
540
540
# # Inserts items from `src` into `dest` at position `pos`. This modifies
541
541
# # `dest` itself, it does not return a copy.
542
542
# #
@@ -574,7 +574,7 @@ template filterIt*(s, pred: untyped): untyped =
574
574
# # Returns a new sequence with all the items of `s` that fulfilled the
575
575
# # predicate `pred`.
576
576
# #
577
- # # Unlike the `filter proc <#filter,openArray[T],proc(T)>`_ and
577
+ # # Unlike the `filter func <#filter,openArray[T],proc(T)>`_ and
578
578
# # `filter iterator<#filter.i,openArray[T],proc(T)>`_,
579
579
# # the predicate needs to be an expression using the ``it`` variable
580
580
# # for testing, like: ``filterIt("abcxyz", it == 'x')``.
@@ -584,7 +584,7 @@ template filterIt*(s, pred: untyped): untyped =
584
584
# #
585
585
# # See also:
586
586
# # * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
587
- # # * `fliter proc <#filter,openArray[T],proc(T)>`_
587
+ # # * `fliter func <#filter,openArray[T],proc(T)>`_
588
588
# # * `filter iterator<#filter.i,openArray[T],proc(T)>`_
589
589
# #
590
590
runnableExamples:
@@ -604,12 +604,12 @@ template keepItIf*(varSeq: seq, pred: untyped) =
604
604
# # Keeps the items in the passed sequence (must be declared as a ``var``)
605
605
# # if they fulfilled the predicate.
606
606
# #
607
- # # Unlike the `keepIf proc <#keepIf,seq[T],proc(T)>`_,
607
+ # # Unlike the `keepIf func <#keepIf,seq[T],proc(T)>`_,
608
608
# # the predicate needs to be an expression using
609
609
# # the ``it`` variable for testing, like: ``keepItIf("abcxyz", it == 'x')``.
610
610
# #
611
611
# # See also:
612
- # # * `keepIf proc <#keepIf,seq[T],proc(T)>`_
612
+ # # * `keepIf func <#keepIf,seq[T],proc(T)>`_
613
613
# # * `filterIt template<#filterIt.t,untyped,untyped>`_
614
614
# #
615
615
runnableExamples:
@@ -648,13 +648,13 @@ since (1, 1):
648
648
if pred: result += 1
649
649
result
650
650
651
- proc all * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): bool =
651
+ func all * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): bool =
652
652
# # Iterates through a container and checks if every item fulfills the
653
653
# # predicate.
654
654
# #
655
655
# # See also:
656
656
# # * `allIt template<#allIt.t,untyped,untyped>`_
657
- # # * `any proc <#any,openArray[T],proc(T)>`_
657
+ # # * `any func <#any,openArray[T],proc(T)>`_
658
658
# #
659
659
runnableExamples:
660
660
let numbers = @ [1 , 4 , 5 , 8 , 9 , 7 , 4 ]
@@ -670,12 +670,12 @@ template allIt*(s, pred: untyped): bool =
670
670
# # Iterates through a container and checks if every item fulfills the
671
671
# # predicate.
672
672
# #
673
- # # Unlike the `all proc <#all,openArray[T],proc(T)>`_,
673
+ # # Unlike the `all func <#all,openArray[T],proc(T)>`_,
674
674
# # the predicate needs to be an expression using
675
675
# # the ``it`` variable for testing, like: ``allIt("abba", it == 'a')``.
676
676
# #
677
677
# # See also:
678
- # # * `all proc <#all,openArray[T],proc(T)>`_
678
+ # # * `all func <#all,openArray[T],proc(T)>`_
679
679
# # * `anyIt template<#anyIt.t,untyped,untyped>`_
680
680
# #
681
681
runnableExamples:
@@ -690,13 +690,13 @@ template allIt*(s, pred: untyped): bool =
690
690
break
691
691
result
692
692
693
- proc any * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): bool =
693
+ func any * [T](s: openArray [T], pred: proc (x: T): bool {.closure .}): bool =
694
694
# # Iterates through a container and checks if some item fulfills the
695
695
# # predicate.
696
696
# #
697
697
# # See also:
698
698
# # * `anyIt template<#anyIt.t,untyped,untyped>`_
699
- # # * `all proc <#all,openArray[T],proc(T)>`_
699
+ # # * `all func <#all,openArray[T],proc(T)>`_
700
700
# #
701
701
runnableExamples:
702
702
let numbers = @ [1 , 4 , 5 , 8 , 9 , 7 , 4 ]
@@ -712,12 +712,12 @@ template anyIt*(s, pred: untyped): bool =
712
712
# # Iterates through a container and checks if some item fulfills the
713
713
# # predicate.
714
714
# #
715
- # # Unlike the `any proc <#any,openArray[T],proc(T)>`_,
715
+ # # Unlike the `any func <#any,openArray[T],proc(T)>`_,
716
716
# # the predicate needs to be an expression using
717
717
# # the ``it`` variable for testing, like: ``anyIt("abba", it == 'a')``.
718
718
# #
719
719
# # See also:
720
- # # * `any proc <#any,openArray[T],proc(T)>`_
720
+ # # * `any func <#any,openArray[T],proc(T)>`_
721
721
# # * `allIt template<#allIt.t,untyped,untyped>`_
722
722
# #
723
723
runnableExamples:
@@ -840,7 +840,7 @@ template foldl*(sequence, operation: untyped): untyped =
840
840
procs = @ [" proc" , " Is" , " Also" , " Fine" ]
841
841
842
842
843
- proc foo (acc, cur: string ): string =
843
+ func foo (acc, cur: string ): string =
844
844
result = acc & cur
845
845
846
846
assert addition == 25 , " Addition is (((5)+9)+11)"
@@ -944,7 +944,7 @@ template mapIt*(s: typed, op: untyped): untyped =
944
944
# #
945
945
# # See also:
946
946
# # * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
947
- # # * `map proc <#map,openArray[T],proc(T)>`_
947
+ # # * `map func <#map,openArray[T],proc(T)>`_
948
948
# # * `applyIt template<#applyIt.t,untyped,untyped>`_ for the in-place version
949
949
# #
950
950
runnableExamples:
@@ -1005,14 +1005,14 @@ template mapIt*(s: typed, op: untyped): untyped =
1005
1005
map (s, f)
1006
1006
1007
1007
template applyIt * (varSeq, op: untyped ) =
1008
- # # Convenience template around the mutable ``apply`` proc to reduce typing.
1008
+ # # Convenience template around the mutable ``apply`` func to reduce typing.
1009
1009
# #
1010
1010
# # The template injects the ``it`` variable which you can use directly in an
1011
1011
# # expression. The expression has to return the same type as the sequence you
1012
1012
# # are mutating.
1013
1013
# #
1014
1014
# # See also:
1015
- # # * `apply proc <#apply,openArray[T],proc(T)_2>`_
1015
+ # # * `apply func <#apply,openArray[T],proc(T)_2>`_
1016
1016
# # * `mapIt template<#mapIt.t,typed,untyped>`_
1017
1017
# #
1018
1018
runnableExamples:
@@ -1048,7 +1048,7 @@ template newSeqWith*(len: int, init: untyped): untyped =
1048
1048
result [i] = init
1049
1049
result
1050
1050
1051
- proc mapLitsImpl (constructor: NimNode ; op: NimNode ; nested: bool ;
1051
+ func mapLitsImpl (constructor: NimNode ; op: NimNode ; nested: bool ;
1052
1052
filter = nnkLiterals): NimNode =
1053
1053
if constructor.kind in filter:
1054
1054
result = newNimNode (nnkCall, lineInfoFrom = constructor)
0 commit comments