Ok so I define 3 lists:
(define mylist '((pause 5 5 5)(note 3 4 5)(pause 3 4 4)))
(define myseqlist '(sequential-music-element (note 5 5 5) (note 4 3 4) (note 5 3 4)))
(define myparlist '(parallel-music-element (note 5 2 5) (note 4 2 4) (note 5 3 1)))
I have the predicates note?
and pause?
, essentially it checks if a list starts with 'note
or 'pause
then returns true or false.
However I can have list containing notes and pauses, which is callled a sequential-music-element (see myseqlist
above) or parallel-music-element (see myparlist
above)
How can I define a function that returns the degree of polyphony, that takes one of the 4 elements as a parameter? (see below for my attempt)
pause
degree of polyphony = 0
note
degree of polyphony = 1
sequence-music-element? return the degree of the child with the largest degree
parallel-music-element? return the sum of the degrees of the children
How do I complete this function:
(define (degree-of-polyphony elem)
(cond [(note? elem) 1]
[(pause? elem) 0]
[(sequential-music-element? elem) (argmax ??? )]))
I am not sure how to make use of argmax in this case. It should check for the highest polyphony for the entire list of elements that degree-of-polyphony
takes as a parameter.
Example: (degree-of-polyphony myseqlist) should return 1 since it has at least one note, if its all pauses, it should return 0.