Nim/tests/typerel/t2plus.nim
2015-09-18 02:24:12 +02:00

22 lines
388 B
Nim

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