# Apply function using level

The following use of Level is documented, without any example. Let's try some simple codes :

In  Level[{a, b, c}, {1}, #^2 &]
Out  a^2

In  Level[{a, b, c}, {1}, #1^2 &]
Out  a^2

In  Level[{a, b, c}, {1}, #2^2 &]
Out  b^2

In  Level[{a, b, c}, {1}, #3^2 &]
Out  c^2


I want a pure function like ??? in

In  Level[{a, b, c}, {1}, ??? &]
Out  {a^2,b^2,c^2}


Of course

In Level[{a, b, c}, {1}, {#1^2,#2^2,#3^2} &]


works but
can it be done without directly referring to the length of the list(=3)
so that it works for arbitrary cases (more complex list and levelspec)?

Indirectly referring the length of a list is OK.

• You can use {##}^2&. – Carl Woll Mar 29 at 20:59
• Thank you. Actually I've tried ##^2& and it produced a^b^c^2. – imida k Mar 29 at 21:08
• You nay also try: Level[{a, b, c}, {0}, #^2 &] – Daniel Huber Mar 30 at 11:27

Background: Level[{a, b}, {1}, f] is f[a, b], f[#] &[a, b] is f[a], and f[##] &[a, b] is f[a,b].
So in your case, you can use Level[{a, b, c}, {1}, {##}^2 &] or Level[{a, b, c}, {0}, #^2 &].