2
$\begingroup$

I thought this was going to be simple. But, I just wanted to print the input and the output of a function as a pair. But, I can't find it. I found this on another questions and this works(this was done by paul:

How to create a list of pairs from 1d list(s)?)

This lead me to solve my own problem, which was to create a generalized inner product list (matching up the i-th element of the first list with the i-th element of the second list), which looks like {{1,a},{2,b},{3,c}}.

Inner[List, A, B, List]

gives

{{1, a}, {2, b}, {3, c}}

Here, List replaces both the multiplication and addition functions in the usual inner product.

But, I would think there would be an easier way. My goal was to have something like this:{(x1,y1),(x2,y2),(x3,y3)......} -> This is a list of pairs. Not a list of list.

Thank you.

$\endgroup$
4
  • 2
    $\begingroup$ How about Thread[{{1, 2, 3}, {a, b, c}}]? $\endgroup$ – bill s Jul 26 '20 at 23:53
  • 3
    $\begingroup$ Or Transpose[{{1, 2, 3}, {a, b, c}}] $\endgroup$ – Bob Hanlon Jul 27 '20 at 0:39
  • $\begingroup$ Thread Works:Thread[{Range[1, m - 1], Table[ModularInverse[x, m], {x, 1, m - 1}]}]. Transpose works:Transpose[{Range[1, m - 1], Table[ModularInverse[x, m], {x, 1, m - 1}]}] My goal was to have something like this:{(x1,y1),(x2,y2),(x3,y3)......} $\endgroup$ – germany1915 Jul 27 '20 at 1:17
  • 3
    $\begingroup$ {#, ModularInverse[#, m]} & /@ Range[1, m - 1]? $\endgroup$ – Rohit Namjoshi Jul 27 '20 at 1:34