Skip to main content
added 30 characters in body
Source Link
MelaGo
  • 9.1k
  • 1
  • 11
  • 26

An old-fashioned solution?

st2[l_] := 
 l[[1, 1]] <> " is " <> ToString[l[[1, 2]]] <> 
  Table[" and " <> l[[n, 1]] <> " is " <> ToString[l[[n, 2]]], {n, 2, Length[l]}]

st2[{{"a", 1}}]

"a is 1"

st2[{{"a", 1}, {"b", 2}}]

"a is 1 and b is 2"

st2[{{"a", 1}, {"b", 2}, {"w", 5}, {"x", 10}}]

"a is 1 and b is 2 and w is 5 and x is 10"

st2[l_] := 
 l[[1, 1]] <> " is " <> ToString[l[[1, 2]]] <> 
  Table[" and " <> l[[n, 1]] <> " is " <> ToString[l[[n, 2]]], {n, 2, Length[l]}]

st2[{{"a", 1}}]

"a is 1"

st2[{{"a", 1}, {"b", 2}}]

"a is 1 and b is 2"

st2[{{"a", 1}, {"b", 2}, {"w", 5}, {"x", 10}}]

"a is 1 and b is 2 and w is 5 and x is 10"

An old-fashioned solution?

st2[l_] := 
 l[[1, 1]] <> " is " <> ToString[l[[1, 2]]] <> 
  Table[" and " <> l[[n, 1]] <> " is " <> ToString[l[[n, 2]]], {n, 2, Length[l]}]

st2[{{"a", 1}}]

"a is 1"

st2[{{"a", 1}, {"b", 2}}]

"a is 1 and b is 2"

st2[{{"a", 1}, {"b", 2}, {"w", 5}, {"x", 10}}]

"a is 1 and b is 2 and w is 5 and x is 10"

Source Link
MelaGo
  • 9.1k
  • 1
  • 11
  • 26

st2[l_] := 
 l[[1, 1]] <> " is " <> ToString[l[[1, 2]]] <> 
  Table[" and " <> l[[n, 1]] <> " is " <> ToString[l[[n, 2]]], {n, 2, Length[l]}]

st2[{{"a", 1}}]

"a is 1"

st2[{{"a", 1}, {"b", 2}}]

"a is 1 and b is 2"

st2[{{"a", 1}, {"b", 2}, {"w", 5}, {"x", 10}}]

"a is 1 and b is 2 and w is 5 and x is 10"