This commit is contained in:
Araq 2015-09-18 01:37:34 +02:00
commit 36f68e1650
7 changed files with 65 additions and 17 deletions

22
tests/typerel/t2plus.nim Normal file
View file

@ -0,0 +1,22 @@
discard """
output: "2.0"
"""
{.warning[TypelessParam]: off.}
import future
# bug #3329
proc foldRight[T,U](lst: seq[T], v: U, f: (T, U) -> U): U =
result = v
for x in lst:
result = f(x, result)
proc mean[T: SomeNumber](xs: seq[T]): T =
xs.foldRight(0.T, (xBAZ: auto, yBAZ: auto) => xBAZ + yBAZ) / T(xs.len)
when isMainModule:
let x = mean(@[1.float, 2, 3])
echo x