rhythm =
#(define-music-function (parser location p) (ly:pitch?)
"Make the rhythm in Mars (the Planets) at the given pitch"
#{ \tuplet 3/2 { $p 8 $p $p } $p 4 $p $p 8 $p $p 4 #})
\new Staff {
\time 5/4
\rhythm c'
\rhythm c''
\rhythm g
}
Hopefully that can be adapted to do what you want! Replace the Mars rhythm with your own. And please note that a space is needed between the variable $p and the durations.
In the LilyPond documentation you can find this example:
Hopefully that can be adapted to do what you want! Replace the Mars rhythm with your own. And please note that a space is needed between the variable
$p
and the durations.