fixes #127
This commit is contained in:
parent
b5d8e8bfaa
commit
04300542da
3 changed files with 30 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
output: "0false"
|
||||
output: "0false12"
|
||||
"""
|
||||
|
||||
# Test multiple generic instantiation of generic proc vars:
|
||||
|
|
@ -17,3 +17,20 @@ proc threadProcWrapper[TMsg]() =
|
|||
threadProcWrapper[int]()
|
||||
threadProcWrapper[bool]()
|
||||
|
||||
type
|
||||
TFilterProc[T,D] = proc (item: T, env:D): bool
|
||||
|
||||
proc filter[T,D](data: seq[T], env:D, pred: TFilterProc[T,D]): seq[T] =
|
||||
result = @[]
|
||||
for e in data:
|
||||
if pred(e, env): result.add(e)
|
||||
|
||||
proc predTest(item: int, value: int): Bool =
|
||||
return item <= value
|
||||
|
||||
proc test(data: seq[int], value: int): seq[int] =
|
||||
return filter(data, value, predTest)
|
||||
|
||||
for x in items(test(@[1,2,3], 2)):
|
||||
stdout.write(x)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue