kriukov / interval-methods

GNU General Public License v3.0
0 stars 2 forks source link

Use `map` #7

Open dpsanders opened 9 years ago

dpsanders commented 9 years ago

For the MultiDimInterval stuff, instead of creating an empty array and using push!, you can just use map, e.g.

julia> set_bigfloat_precision(64)
64

julia> l = [Interval(0.1), Interval(0.2)]
2-element Array{Interval,1}:
 Interval(9.99999999999999999946e-02 with 64 bits of precision,1.00000000000000000001e-01 with 64 bits of precision)
 Interval(1.99999999999999999989e-01 with 64 bits of precision,2.00000000000000000003e-01 with 64 bits of precision)

julia> map(mid, l)
2-element Array{BigFloat,1}:
 1.00000000000000000001e-01
 2.00000000000000000003e-01
dpsanders commented 9 years ago

You can then use metaprogramming to define all of these functions in one go.

kriukov commented 9 years ago

Done, but not yet with metaprogramming.

David Sanders wrote:

You can then use metaprogramming to define all of these functions in one go.

— Reply to this email directly or view it on GitHub https://github.com/kriukov/interval-methods/issues/7#issuecomment-60642831.