Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert separators between columns?

Tags:

raku

I have columns in @columns:

my @columns =('column1', 'column2', 'column3');

and I have separators in @separators:

my @separators = (',', '|');

I want to insert the separators between columns, one by one:

column1,column2|column

my solution is:

(@columns »~» (|@separators,"")).join("")

Here I have three columns and two separators, and how about insert N-1 separators between N columns?

like image 821
chenyf Avatar asked Jul 26 '18 15:07

chenyf


1 Answers

Assuming that @separators has the right number of values, you could use roundrobin.

roundrobin( @columns, @separators ).flat.join()
like image 102
Brad Gilbert Avatar answered Dec 28 '22 21:12

Brad Gilbert