1

So this does what I want:

#1 <> #2 &["♠", "A"]

♠A

The output is fine. How do I quickly apply this to the list

{{"♠", "A"}, {"♢", "A"}, {"♣", "A"}, {"♡", "A"}}

So that I can combined all of the suits with the Aces? I have tried a mixture of "/", "@" and "/@". None of these worked.

enter image description here

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Chen Stats Yu
  • 4,986
  • 2
  • 24
  • 50

1 Answers1

4

You want to Apply your function at level 1 in the list :

#1 <> #2 & @@@ {{"♠", "A"}, {"♢", "A"}, {"♣", "A"}, {"♡", "A"}}
{"♠A", "♢A", "♣A", "♡A"}

As mentioned at the very top of the docs for Apply, f @@@ expr is is syntactic sugar for Apply[ f, expr, {1} ], and has the same effect as Apply[ f, # ]& /@ expr.


Note that #1 <> #2 & parses as StringJoin[#1,#2]&, for which you might as well just use StringJoin :

StringJoin @@@ {{"♠", "A"}, {"♢", "A"}, {"♣", "A"}, {"♡", "A"}}
{"♠A", "♢A", "♣A", "♡A"}
jjc385
  • 3,473
  • 1
  • 17
  • 29