Sat Jun 25, 2022 7:17 pm
Login Register Lost Password? Contact Us

Please Note: The HPCC Systems forums are moving to Stack Overflow. We invite you to post your questions on Stack Overflow utilizing the tag hpcc-ecl (https://stackoverflow.com/search?tab=newest&q=hpcc-ecl). This legacy forum will be active and monitored during our transition to Stack Overflow but will become read only beginning September 1, 2022.



Conversão SET OF STRING para STRING

Fórum em português para questões gerais e suporte relacionados a ECL/HPCC Systems.

Moderator: hwatanuki

Tue Jun 01, 2021 12:32 pm Change Time Zone

Olá,

É possível converter um SET OF STRING para STRING de forma direta?

Exemplo:
Entrada -> ['A','B','C']
Saída (Esperada) -> 'ABC'

Caso não seja possível de forma direta, existe alguma maneira para realizar esta operação?

Desde já agradeço.
eidg
 
Posts: 1
Joined: Tue Jun 01, 2021 12:25 pm

Tue Jun 01, 2021 6:39 pm Change Time Zone

federal,

Here's a simple function that does what you need:
Code: Select all
oneStr(SET OF STRING s) := FUNCTION
  ds := DATASET(s,{STRING c}); //treat the set as a dataset
  RETURN ROLLUP(ds,TRUE,TRANSFORM({STRING c},SELF.c := LEFT.c + RIGHT.c))[1].c;
      //roll up to a one-record dataset and return the c field value from that record
END;

setStr := ['A', 'B', 'C'];
oneStr(setStr);

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1619
Joined: Wed Oct 26, 2011 7:40 pm


Return to Português

Who is online

Users browsing this forum: No registered users and 1 guest

cron