I honestly don't see an issue with your solution that uses a filter. That's how
it would be done in any other language. If you don't want the extra proc
definition, you can use the `=>` sugar like you did with map:
import os, strutils, sequtils, sugar
proc main() =
if paramCount() < 1:
quit("Usage: x-sexpr.x 1000")
let
s = readFile(paramStr(1)).split(Whitespace+{','})
xs= s.filter(x => x.len > 0).map(x => parseFloat x)
echo "Average= ", xs.foldl(a + b)/float(xs.len)
main()
Run
- split does not seem to work properly edu500ac
- Re: split does not seem to work properly Araq
- Re: split does not seem to work properly miran
- Re: split does not seem to work properly edu500ac
- Re: split does not seem to work properly jyapayne
