This is the function I came up with:
Flatten[ConstantArray @@@ FactorInteger[#]] &
Is there a way to write this cleaner or point-free?
Update: I only have Mathematica 12 Student Edition. Seems like MapApply is new in 13.1.
Notes on Point-Free
Point-free style, also known as tacit programming, defines functions without reference to formal arguments. See wikipedia: Tacit programming, YouTube: Point-free or Die. In the Wolfram Language, a point-free alternate to f[x_] := g[h[x]]
would be f = g @* h
. There are also some built in forms that facilitate a point-free style: Map[f, #]&
becomes Map[f]
; SortBy[#, f]&
becomes SortBy[f]
; StringReplace[#, rules]&
becomes StringReplace[rules]
. Mathematica provides these functions in non-curried and curried forms. Partial application is demonstrated here with the curried form. The benefit of point-free style is emphasis on function composition instead of the arguments.
@*
versus Apply@@
. $\endgroup$