You can find the anonymous function reader macro here
Anonymous function literal (#())
#(...) => (fn [args] (...))
where args are determined by the presence of argument literals taking the form %, %n or %&. % is a synonym for %1, %n designates the nth arg (1-based), and %& designates a rest arg. This is not a replacement for fn - idiomatic used would be for very short one-off mapping/filter fns and the like. #() forms cannot be nested.
%
or %1
refers to the first argument and %2
refers to the second.
In your case, in the first approach, %
refers to ""
and %2
refers to the vector of integers;
in the second approach, %
to the vector of integers.
As for the difference between reduce
and apply
here, reduce
provides an supplied val
, and in your case ""
. Without this ""
, reduce
would call str
with 115
and (char 101)
, which would produce "115e"
. Instead of calling str
with the first and second element in your vector, you should call str
with an empty string and the first element of your vector, which would produce "s"
. And in the next reduce loop, str
would be called with the parameter "s"
and 101
, yielding "se"
, and so on.
And for the apply
call, you've mapped char
to the vector of integer before you call apply
, thus the parameter of apply
would be: 1. the function str
; 2.a vector of characters the function map
produced.
Also, you can check out more information about differences between apply
and reduce
in this question.