Reputation: 2186
Given these two lists:
l1 = ['a', 'b', 'c']
l2 = ["Foo", "bar", "baz"]
For each item in l1
, I want to run a func with each item in l2
something like:
Enum.each(l1, &(fun1(&1, < each_item_in_l2 >)
Is there a short way of doing that?
Upvotes: 1
Views: 2617
Reputation: 196
Yes, you can use comprehension, here's a quick example for iex:
for abc <- ['a', 'b', 'c'],
foobar <- ["Foo", "bar", "baz"] do
IO.inspect "#{abc} #{foobar}"
end
Upvotes: 6