Find unique items in toml table

Hello,

I have a collection of albums, with an index.md file for each album, containing in the front matter tables with the tracks. For example:

[[tracks]]
track = "01"
title = "Chromatic fantasy and fugue in D minor, BWV 903"
composer = "Johann Sebastian Bach"
duration = "14:28"
[[tracks]]
track = "02"
title = "Italian concerto in F major, BWV 971"
composer = "Johann Sebastian Bach"
duration = "04:03"

When I display the page corresponding to each album, I would like to determine whether there is a single “composer” for all tracks (in order to display it differently in that case). I have not found a simpler way than doing this:

{{ with .Params.tracks }}
{{ range .  }}
  {{ $.Scratch.Add "composer" ( slice .composer ) }}
{{ end }}
{{ end }}
{{ $composer:= uniq ($.Scratch.Get "composer") }}
{{ len $composer }} --> returns the number of elements in $composer

Seems complicated…but it works. Is there a simpler way of doing this that I am missing ?
I could not get “group” to work.
Any help would be appreaciated.

I can’t think of a better way to do that.

Thanks. Am new to Hugo and appreciate the help.