t2plus.nim 379 B

1234567891011121314151617181920212223
  1. discard """
  2. output: "2.0"
  3. """
  4. {.warning[TypelessParam]: off.}
  5. import sugar
  6. # bug #3329
  7. proc foldRight[T,U](lst: seq[T], v: U, f: (T, U) -> U): U =
  8. result = v
  9. for x in lst:
  10. result = f(x, result)
  11. proc mean[T: SomeNumber](xs: seq[T]): T =
  12. xs.foldRight(0.T, (xBAZ: auto, yBAZ: auto) => xBAZ + yBAZ) / T(xs.len)
  13. when true:
  14. let x = mean(@[1.float, 2, 3])
  15. echo x