parent
518b794491
commit
4b09a89758
3 changed files with 47 additions and 3 deletions
26
tests/iter/titerable.nim
Normal file
26
tests/iter/titerable.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
discard """
|
||||
output: '''2
|
||||
4
|
||||
6
|
||||
4
|
||||
8
|
||||
12
|
||||
'''
|
||||
"""
|
||||
|
||||
iterator map[T, U](s: iterator:T{.inline.}, f: proc(x: T): U): U =
|
||||
for e in s: yield f(e)
|
||||
|
||||
template toSeq(s: expr): expr =
|
||||
var res = newSeq[type(s)](0)
|
||||
for e in s: res.add(e)
|
||||
res
|
||||
|
||||
var s1 = @[1, 2, 3]
|
||||
for x in map(s1.items, proc (a:int): int = a*2):
|
||||
echo x
|
||||
|
||||
var s2 = toSeq(map(s1.items, proc (a:int): int = a*4))
|
||||
for x in s2:
|
||||
echo x
|
||||
|
||||
12
tests/overload/tissue966.nim
Normal file
12
tests/overload/tissue966.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
discard """
|
||||
msg: 'type mismatch: got (PTest)'
|
||||
"""
|
||||
|
||||
type
|
||||
PTest = ref object
|
||||
|
||||
proc test(x: PTest, y: int) = nil
|
||||
|
||||
var buf: PTest
|
||||
buf.test()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue