3 ms·
Perhaps, but you aren't saving a ton of typing if you still need to specify all the types. I think you can get away with xs.morph(x => x*x) because you kn
by nemo1618 10y ago
Perhaps, but you aren't saving a ton of typing if you still need to specify all the types. I think you can get away with
xs.morph(x => x*x)
because you know that xs is a slice of ints, so x must be an int, and that means x*x is an int, so the lambda has the right type signature.
As far as I can see, there are two potential annoyances with this approach: you have to explicitly cast constants sometimes (e.g. uint64(3) instead of just 3), and you have to explicitly cast values if you want to return an interface (e.g. io.Writer(file) instead of just file). But these cases are rare enough that I think the tradeoff is worth it.