5
$\begingroup$

Liking the headings and spacing allowed by Row[] and TableForm[] I set up the below with 3 TableForm[]'s to use as a model from which to generalize, using a pure function, to display a list of 3-ples, coEffs10.
The lower Row[...], is the general one, using one TableForm[], and provides correct output, but uses 2 pure functions - I couldn't do it in 1.

  1. I'm curious to see the same output produced with Row[TableForm[...]] but using only a single pure function.
  2. Also, keeping the pair of pf's, but disentangling them to the point that they could both be put in " |-> " form, which I was unable to do.

I suspect the answers are implicit in 38393, but are too subtle for me.

Thanks.

coEffs10={{1,2,0},{2,3,0},{3,5,1},{4,7,5},{5,11,3},{6,13,0},{7,17,7},{8,19,10},{9,23,3},
          {10,29,3},{11,31,30},{12,37,25},{13,41,18},{14,43,16},{15,47,19}};

tH = {None, {"n", "p[n]", "cof"}};
Row[{
     TableForm[coEffs10[[1 + 0*5 ;; (0+1)*5]] , TableAlignments -> Right, TableSpacing -> {1,2}, TableHeadings -> tH],
     TableForm[coEffs10[[1 + 1*5 ;; (1+1)*5]] , TableAlignments -> Right, TableSpacing -> {1,2}, TableHeadings -> tH],
     TableForm[coEffs10[[1 + 2*5 ;; (2+1)*5]] , TableAlignments -> Right, TableSpacing -> {1,2}, TableHeadings -> tH]
     },
     Spacer[43]
     ]

The below generalizes above, but uses 2 pure functions. Can it be done with one?

Row[
    TableForm[coEffs10[[1 + (#1-1) 5 ;; #1 5]]&[#],
       TableAlignments -> Right, TableSpacing -> {1,2}, TableHeadings -> tH]& /@ Range[3],
    Spacer[43]
   ]  

Output produced by both above

$\endgroup$
8
$\begingroup$
Row[TableForm[coEffs10[[1 + (# - 1) 5 ;; # 5]] , 
    TableAlignments -> Right, TableSpacing -> {1, 2}, 
    TableHeadings -> tH] & /@ Range[3], Spacer[43]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.