stefano franchi <stefano.fran...@gmail.com> writes: > Is there a lilypond function that would allow me to extract a subset from a > pattern? > > For instance, let's say I have a simple A - natural scale and I want to get > the first five notes. Is there a function, call it \pick, that would allow > me to do something like: > > \scale = { a b c d e f g} > \pick 0 4 \scale > > and return {a b c d e} ? > > Could not find anything in the manuals, but I may be lacking the right > terms to search for.
Here is an example implementation. Negative numbers in the first element count from the end of the list, negative numbers in the second element indicate the elements to be removed from the right rather than taken from the left (-1 removes none, -2 removes 1, -3 removes 2: slightly awkward but 0 already means "leave no element" and so cannot simultaneously mean "remove no element"). The music in question needs to actually be of a kind that has an 'elements field. -- David Kastrup