How do i convert a global 1D-Array of integers into a composed string

i tried with c_str - i tried with to_string - and several other ideas, but all failed. It should be trivial for C++ experts but i am just a c++ beginner !

Background: i do some calculations inside LAMBDA and want to see the intermediate results of the array without extracting every single value by templating…

Can you show us your yaml / lambda so far?

Hi, in the meantime i asked ChatGPT and got somenthing, but Synthax did no really fit, but gave good hints. After some back and forth, the following code worked and gave exactly the string i needed:

# Globals zur übergreifenden Verwendung in allen LAMBDAs
# --------------------------------------------------------
globals:
    # ------------
    # interne variablen  ->
    # ------------
  - id: my_global_array
    type: int[5]
    initial_value: '{1, 2, 13, 4, 15}'

text_sensor:
  - platform: template
    name: output1
    id: string_output
    lambda: |-
      std::string result;
      int i ;
      for ( i = 0; i < 5; ++i) 
      {
        result += to_string(id(my_global_array)[i]);
        if (i < 4 ) {
        result += ","; // Add a comma between numbers 
        }
      }
      return result;
    #
    #


what did not worked as suggested by ChatGPT was the lenght of the array:
like

id(my_global_array).size()

which gave a compilation error…
Any ideas ??