`sum` from `math` works on openArrays, but what you have supplied is an 
iterator. Unfortunately, the support for iterator adapters/consumers is poor in 
Nim at the moment.

It seems that the idiomatic way is collecting to a sequence and then summing 
(or, in other cases, acting on the values of the new collection) which is 
conceptually looks like a hack and is a tradeoff, when compared to a simple 
loop.

Until a proper supports lands in the language, I get by with 
[zero_functional](https://github.com/zero-functional/zero-functional) lib, 
which allows the following syntax. The lib is not without its own quirks and 
limitations, though, but it works rather well for basic stuff. 
    
    
    import tables, zero_functional
    let table = {"foo": 1, "bar": 2, "baz": 3}.toTable
    echo table.values --> drop(1).map(it * 2).sum()
    
    Run

Reply via email to