Use an anonymous function: map(x->myround(x, 2), a)
On Thursday, January 14, 2016 at 3:05:15 PM UTC+1, [email protected] wrote: > > Hello, > > how can I pass one or more additional (constant) argument(s) to a > function applied via the map() function to an array? > > I tried to search for a solution and also stumbled upon a posting [1] > which touches a similar topic but unfortunately does not answer my > question. > > > Minimal (rather artificial :) example: > > function myround(x::Float64, digits::Integer) > round(x, digits) > end > > a = log(2:5) > map(myround, a) > > Question: How can I pass the digits argument to the calls of round > within map? 'map(myround, a, 2)' only processes the first element. > > Thanks in advance! > > Best, > Michael > > [1] https://groups.google.com/forum/#!topic/julia-users/eD52IwO-qFw > >
