Determine the depth of an array
K, 4 bytes

#,/\


In K, ,/ will join all the elements of a list. The common idiom ,// iterates to a fixed point, flattening an arbitrarily nested list completely. ,/\ will iterate to a fixed point in a similar way, but gather a list of intermediate results. By counting how many intermediate results we visit before reaching the fixed point (#), we get the answer we want: the maximum nesting depth.

"Count of join over fixed-point scan".

In action:

 (#,/\)'(,1
        1 2 3
        ,1 2 3
        (3;(3;,3;3);3)
        ,((,1;2);(3;,4)))
1 1 2 3 4