Skip to content

Commit 38eb021

Browse files
authored
sequtils.nim: Change some func back to proc (#16309)
This commit changes the funcs that take a `proc` parameter back to procs. This reverts some of commit 6f57eba: sequtils.nim: Use `func` (#16293) See also: - #16303 - #16304
1 parent 233c6a2 commit 38eb021

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

lib/pure/collections/sequtils.nim

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func distribute*[T](s: seq[T], num: Positive, spread = true): seq[seq[T]] =
359359
result[i].add(s[g])
360360
first = last
361361

362-
func map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
362+
proc map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
363363
seq[S]{.inline.} =
364364
## Returns a new sequence with the results of `op` proc applied to every
365365
## item in the container `s`.
@@ -373,7 +373,7 @@ func map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
373373
## See also:
374374
## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
375375
## * `mapIt template<#mapIt.t,typed,untyped>`_
376-
## * `apply func<#apply,openArray[T],proc(T)_2>`_ for the in-place version
376+
## * `apply proc<#apply,openArray[T],proc(T)_2>`_ for the in-place version
377377
##
378378
runnableExamples:
379379
let
@@ -385,7 +385,7 @@ func map*[T, S](s: openArray[T], op: proc (x: T): S {.closure.}):
385385
for i in 0 ..< s.len:
386386
result[i] = op(s[i])
387387

388-
func apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
388+
proc apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
389389
{.inline.} =
390390
## Applies `op` to every item in `s` modifying it directly.
391391
##
@@ -396,7 +396,7 @@ func apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
396396
##
397397
## See also:
398398
## * `applyIt template<#applyIt.t,untyped,untyped>`_
399-
## * `map func<#map,openArray[T],proc(T)>`_
399+
## * `map proc<#map,openArray[T],proc(T)>`_
400400
##
401401
runnableExamples:
402402
var a = @["1", "2", "3", "4"]
@@ -405,7 +405,7 @@ func apply*[T](s: var openArray[T], op: proc (x: var T) {.closure.})
405405

406406
for i in 0 ..< s.len: op(s[i])
407407

408-
func apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
408+
proc apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
409409
{.inline.} =
410410
## Applies `op` to every item in `s` modifying it directly.
411411
##
@@ -416,7 +416,7 @@ func apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
416416
##
417417
## See also:
418418
## * `applyIt template<#applyIt.t,untyped,untyped>`_
419-
## * `map func<#map,openArray[T],proc(T)>`_
419+
## * `map proc<#map,openArray[T],proc(T)>`_
420420
##
421421
runnableExamples:
422422
var a = @["1", "2", "3", "4"]
@@ -425,7 +425,7 @@ func apply*[T](s: var openArray[T], op: proc (x: T): T {.closure.})
425425

426426
for i in 0 ..< s.len: s[i] = op(s[i])
427427

428-
func apply*[T](s: openArray[T], op: proc (x: T) {.closure.}) {.inline, since: (1, 3).} =
428+
proc apply*[T](s: openArray[T], op: proc (x: T) {.closure.}) {.inline, since: (1, 3).} =
429429
## Same as `apply` but for proc that do not return and do not mutate `s` directly.
430430
runnableExamples:
431431
var message: string
@@ -442,7 +442,7 @@ iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T =
442442
##
443443
## See also:
444444
## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
445-
## * `fliter func<#filter,openArray[T],proc(T)>`_
445+
## * `fliter proc<#filter,openArray[T],proc(T)>`_
446446
## * `filterIt template<#filterIt.t,untyped,untyped>`_
447447
##
448448
runnableExamples:
@@ -456,7 +456,7 @@ iterator filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): T =
456456
if pred(s[i]):
457457
yield s[i]
458458

459-
func filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
459+
proc filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
460460
{.inline.} =
461461
## Returns a new sequence with all the items of `s` that fulfilled the
462462
## predicate `pred` (function that returns a `bool`).
@@ -468,7 +468,7 @@ func filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
468468
## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
469469
## * `filterIt template<#filterIt.t,untyped,untyped>`_
470470
## * `filter iterator<#filter.i,openArray[T],proc(T)>`_
471-
## * `keepIf func<#keepIf,seq[T],proc(T)>`_ for the in-place version
471+
## * `keepIf proc<#keepIf,seq[T],proc(T)>`_ for the in-place version
472472
##
473473
runnableExamples:
474474
let
@@ -483,19 +483,19 @@ func filter*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): seq[T]
483483
if pred(s[i]):
484484
result.add(s[i])
485485

486-
func keepIf*[T](s: var seq[T], pred: proc(x: T): bool {.closure.})
486+
proc keepIf*[T](s: var seq[T], pred: proc(x: T): bool {.closure.})
487487
{.inline.} =
488488
## Keeps the items in the passed sequence `s` if they fulfilled the
489489
## predicate `pred` (function that returns a `bool`).
490490
##
491491
## Note that `s` must be declared as a ``var``.
492492
##
493-
## Similar to the `filter func<#filter,openArray[T],proc(T)>`_,
493+
## Similar to the `filter proc<#filter,openArray[T],proc(T)>`_,
494494
## but modifies the sequence directly.
495495
##
496496
## See also:
497497
## * `keepItIf template<#keepItIf.t,seq,untyped>`_
498-
## * `filter func<#filter,openArray[T],proc(T)>`_
498+
## * `filter proc<#filter,openArray[T],proc(T)>`_
499499
##
500500
runnableExamples:
501501
var floats = @[13.0, 12.5, 5.8, 2.0, 6.1, 9.9, 10.1]
@@ -576,7 +576,7 @@ template filterIt*(s, pred: untyped): untyped =
576576
## Returns a new sequence with all the items of `s` that fulfilled the
577577
## predicate `pred`.
578578
##
579-
## Unlike the `filter func<#filter,openArray[T],proc(T)>`_ and
579+
## Unlike the `filter proc<#filter,openArray[T],proc(T)>`_ and
580580
## `filter iterator<#filter.i,openArray[T],proc(T)>`_,
581581
## the predicate needs to be an expression using the `it` variable
582582
## for testing, like: `filterIt("abcxyz", it == 'x')`.
@@ -586,7 +586,7 @@ template filterIt*(s, pred: untyped): untyped =
586586
##
587587
## See also:
588588
## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
589-
## * `fliter func<#filter,openArray[T],proc(T)>`_
589+
## * `fliter proc<#filter,openArray[T],proc(T)>`_
590590
## * `filter iterator<#filter.i,openArray[T],proc(T)>`_
591591
##
592592
runnableExamples:
@@ -606,12 +606,12 @@ template keepItIf*(varSeq: seq, pred: untyped) =
606606
## Keeps the items in the passed sequence (must be declared as a `var`)
607607
## if they fulfilled the predicate.
608608
##
609-
## Unlike the `keepIf func<#keepIf,seq[T],proc(T)>`_,
609+
## Unlike the `keepIf proc<#keepIf,seq[T],proc(T)>`_,
610610
## the predicate needs to be an expression using
611611
## the `it` variable for testing, like: `keepItIf("abcxyz", it == 'x')`.
612612
##
613613
## See also:
614-
## * `keepIf func<#keepIf,seq[T],proc(T)>`_
614+
## * `keepIf proc<#keepIf,seq[T],proc(T)>`_
615615
## * `filterIt template<#filterIt.t,untyped,untyped>`_
616616
##
617617
runnableExamples:
@@ -650,13 +650,13 @@ since (1, 1):
650650
if pred: result += 1
651651
result
652652

653-
func all*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool =
653+
proc all*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool =
654654
## Iterates through a container and checks if every item fulfills the
655655
## predicate.
656656
##
657657
## See also:
658658
## * `allIt template<#allIt.t,untyped,untyped>`_
659-
## * `any func<#any,openArray[T],proc(T)>`_
659+
## * `any proc<#any,openArray[T],proc(T)>`_
660660
##
661661
runnableExamples:
662662
let numbers = @[1, 4, 5, 8, 9, 7, 4]
@@ -672,12 +672,12 @@ template allIt*(s, pred: untyped): bool =
672672
## Iterates through a container and checks if every item fulfills the
673673
## predicate.
674674
##
675-
## Unlike the `all func<#all,openArray[T],proc(T)>`_,
675+
## Unlike the `all proc<#all,openArray[T],proc(T)>`_,
676676
## the predicate needs to be an expression using
677677
## the `it` variable for testing, like: `allIt("abba", it == 'a')`.
678678
##
679679
## See also:
680-
## * `all func<#all,openArray[T],proc(T)>`_
680+
## * `all proc<#all,openArray[T],proc(T)>`_
681681
## * `anyIt template<#anyIt.t,untyped,untyped>`_
682682
##
683683
runnableExamples:
@@ -692,13 +692,13 @@ template allIt*(s, pred: untyped): bool =
692692
break
693693
result
694694

695-
func any*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool =
695+
proc any*[T](s: openArray[T], pred: proc(x: T): bool {.closure.}): bool =
696696
## Iterates through a container and checks if some item fulfills the
697697
## predicate.
698698
##
699699
## See also:
700700
## * `anyIt template<#anyIt.t,untyped,untyped>`_
701-
## * `all func<#all,openArray[T],proc(T)>`_
701+
## * `all proc<#all,openArray[T],proc(T)>`_
702702
##
703703
runnableExamples:
704704
let numbers = @[1, 4, 5, 8, 9, 7, 4]
@@ -714,12 +714,12 @@ template anyIt*(s, pred: untyped): bool =
714714
## Iterates through a container and checks if some item fulfills the
715715
## predicate.
716716
##
717-
## Unlike the `any func<#any,openArray[T],proc(T)>`_,
717+
## Unlike the `any proc<#any,openArray[T],proc(T)>`_,
718718
## the predicate needs to be an expression using
719719
## the `it` variable for testing, like: `anyIt("abba", it == 'a')`.
720720
##
721721
## See also:
722-
## * `any func<#any,openArray[T],proc(T)>`_
722+
## * `any proc<#any,openArray[T],proc(T)>`_
723723
## * `allIt template<#allIt.t,untyped,untyped>`_
724724
##
725725
runnableExamples:
@@ -946,7 +946,7 @@ template mapIt*(s: typed, op: untyped): untyped =
946946
##
947947
## See also:
948948
## * `sugar.collect macro<sugar.html#collect.m%2Cuntyped%2Cuntyped>`_
949-
## * `map func<#map,openArray[T],proc(T)>`_
949+
## * `map proc<#map,openArray[T],proc(T)>`_
950950
## * `applyIt template<#applyIt.t,untyped,untyped>`_ for the in-place version
951951
##
952952
runnableExamples:
@@ -1007,14 +1007,14 @@ template mapIt*(s: typed, op: untyped): untyped =
10071007
map(s, f)
10081008

10091009
template applyIt*(varSeq, op: untyped) =
1010-
## Convenience template around the mutable `apply` func to reduce typing.
1010+
## Convenience template around the mutable `apply` proc to reduce typing.
10111011
##
10121012
## The template injects the `it` variable which you can use directly in an
10131013
## expression. The expression has to return the same type as the sequence you
10141014
## are mutating.
10151015
##
10161016
## See also:
1017-
## * `apply func<#apply,openArray[T],proc(T)_2>`_
1017+
## * `apply proc<#apply,openArray[T],proc(T)_2>`_
10181018
## * `mapIt template<#mapIt.t,typed,untyped>`_
10191019
##
10201020
runnableExamples:

0 commit comments

Comments
 (0)