1

Here are two STRING vectors:

a = `A`B`C
b = `oo`pp`qq

I want to combine each element of the vectors. I can do it with a two-level for loop:

result = array(STRING)
for(x in a){
    for(y in b){
        result.append!(x+y)
    }
}

But I want an easier way. How can I do this?

dbaa9948
  • 189
  • 2
  • 10

2 Answers2

3

You can use eachLeft or eachRight to get your desired result. Here is an example of the usage of eachLeft:

result = eachLeft(+,a,b).flatten()
lulunolemon
  • 219
  • 3
1
a = `A`B`C
b = `oo`pp`qq
each(add{a}, b).flatten()
Hanwei Tang
  • 413
  • 3
  • 10