Combine `Table` with `Riffle`

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have table of function f[x,a]. For the sake of easy reproduction, let's limit it to a few entries - the original is over 1000 x 1000:



actualtable=Table[f[x, a], x, 0, 4, a, 1, 4]
*f[0, 1], f[0, 2], f[0, 3], f[0, 4], f[1, 1], f[1, 2], f[1, 3],
f[1, 4], f[2, 1], f[2, 2], f[2, 3], f[2, 4], f[3, 1], f[3, 2],
f[3, 3], f[3, 4], f[4, 1], f[4, 2], f[4, 3], f[4, 4]*


I want to find a way to interject a value m between each list item, to create



desiredtable=f[0, 1], m, f[0, 2], m, f[0, 3], m, f[0, 4], f[1, 1], m, f[1, 2], 
m, f[1, 3], m, f[1, 4], f[2, 1], m, f[2, 2], m, f[2, 3], m,
f[2, 4], f[3, 1], m, f[3, 2], m, f[3, 3], m, f[3, 4], f[4, 1],
m, f[4, 2], m, f[4, 3], m, f[4, 4]


I tried using Riffle in conjunction with Table, but it only injects m in between lines, rather than in between individual entries.



Obviously, with a tiny table like this, it's easy, I can just type in the ms, or type the Riffle command once for each line of the output.



But for a very big table, how do I do it?










share|improve this question

























    up vote
    3
    down vote

    favorite












    I have table of function f[x,a]. For the sake of easy reproduction, let's limit it to a few entries - the original is over 1000 x 1000:



    actualtable=Table[f[x, a], x, 0, 4, a, 1, 4]
    *f[0, 1], f[0, 2], f[0, 3], f[0, 4], f[1, 1], f[1, 2], f[1, 3],
    f[1, 4], f[2, 1], f[2, 2], f[2, 3], f[2, 4], f[3, 1], f[3, 2],
    f[3, 3], f[3, 4], f[4, 1], f[4, 2], f[4, 3], f[4, 4]*


    I want to find a way to interject a value m between each list item, to create



    desiredtable=f[0, 1], m, f[0, 2], m, f[0, 3], m, f[0, 4], f[1, 1], m, f[1, 2], 
    m, f[1, 3], m, f[1, 4], f[2, 1], m, f[2, 2], m, f[2, 3], m,
    f[2, 4], f[3, 1], m, f[3, 2], m, f[3, 3], m, f[3, 4], f[4, 1],
    m, f[4, 2], m, f[4, 3], m, f[4, 4]


    I tried using Riffle in conjunction with Table, but it only injects m in between lines, rather than in between individual entries.



    Obviously, with a tiny table like this, it's easy, I can just type in the ms, or type the Riffle command once for each line of the output.



    But for a very big table, how do I do it?










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I have table of function f[x,a]. For the sake of easy reproduction, let's limit it to a few entries - the original is over 1000 x 1000:



      actualtable=Table[f[x, a], x, 0, 4, a, 1, 4]
      *f[0, 1], f[0, 2], f[0, 3], f[0, 4], f[1, 1], f[1, 2], f[1, 3],
      f[1, 4], f[2, 1], f[2, 2], f[2, 3], f[2, 4], f[3, 1], f[3, 2],
      f[3, 3], f[3, 4], f[4, 1], f[4, 2], f[4, 3], f[4, 4]*


      I want to find a way to interject a value m between each list item, to create



      desiredtable=f[0, 1], m, f[0, 2], m, f[0, 3], m, f[0, 4], f[1, 1], m, f[1, 2], 
      m, f[1, 3], m, f[1, 4], f[2, 1], m, f[2, 2], m, f[2, 3], m,
      f[2, 4], f[3, 1], m, f[3, 2], m, f[3, 3], m, f[3, 4], f[4, 1],
      m, f[4, 2], m, f[4, 3], m, f[4, 4]


      I tried using Riffle in conjunction with Table, but it only injects m in between lines, rather than in between individual entries.



      Obviously, with a tiny table like this, it's easy, I can just type in the ms, or type the Riffle command once for each line of the output.



      But for a very big table, how do I do it?










      share|improve this question













      I have table of function f[x,a]. For the sake of easy reproduction, let's limit it to a few entries - the original is over 1000 x 1000:



      actualtable=Table[f[x, a], x, 0, 4, a, 1, 4]
      *f[0, 1], f[0, 2], f[0, 3], f[0, 4], f[1, 1], f[1, 2], f[1, 3],
      f[1, 4], f[2, 1], f[2, 2], f[2, 3], f[2, 4], f[3, 1], f[3, 2],
      f[3, 3], f[3, 4], f[4, 1], f[4, 2], f[4, 3], f[4, 4]*


      I want to find a way to interject a value m between each list item, to create



      desiredtable=f[0, 1], m, f[0, 2], m, f[0, 3], m, f[0, 4], f[1, 1], m, f[1, 2], 
      m, f[1, 3], m, f[1, 4], f[2, 1], m, f[2, 2], m, f[2, 3], m,
      f[2, 4], f[3, 1], m, f[3, 2], m, f[3, 3], m, f[3, 4], f[4, 1],
      m, f[4, 2], m, f[4, 3], m, f[4, 4]


      I tried using Riffle in conjunction with Table, but it only injects m in between lines, rather than in between individual entries.



      Obviously, with a tiny table like this, it's easy, I can just type in the ms, or type the Riffle command once for each line of the output.



      But for a very big table, how do I do it?







      list-manipulation table






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Richard Burke-Ward

      3237




      3237




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Map Riffle to each of the element of actualTable:



           desiredtable = Riffle[#, "m"] & /@ actualtable


          (* f[0, 1], "m", f[0, 2], "m", f[0, 3], "m", f[0, 4], f[1, 1], "m",
          f[1, 2], "m", f[1, 3], "m", f[1, 4], f[2, 1], "m", f[2, 2], "m",
          f[2, 3], "m", f[2, 4], f[3, 1], "m", f[3, 2], "m", f[3, 3], "m",
          f[3, 4], f[4, 1], "m", f[4, 2], "m", f[4, 3], "m", f[4, 4]*)






          share|improve this answer




















          • Perfect. Thanks.
            – Richard Burke-Ward
            1 hour ago










          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181995%2fcombine-table-with-riffle%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          Map Riffle to each of the element of actualTable:



           desiredtable = Riffle[#, "m"] & /@ actualtable


          (* f[0, 1], "m", f[0, 2], "m", f[0, 3], "m", f[0, 4], f[1, 1], "m",
          f[1, 2], "m", f[1, 3], "m", f[1, 4], f[2, 1], "m", f[2, 2], "m",
          f[2, 3], "m", f[2, 4], f[3, 1], "m", f[3, 2], "m", f[3, 3], "m",
          f[3, 4], f[4, 1], "m", f[4, 2], "m", f[4, 3], "m", f[4, 4]*)






          share|improve this answer




















          • Perfect. Thanks.
            – Richard Burke-Ward
            1 hour ago














          up vote
          2
          down vote



          accepted










          Map Riffle to each of the element of actualTable:



           desiredtable = Riffle[#, "m"] & /@ actualtable


          (* f[0, 1], "m", f[0, 2], "m", f[0, 3], "m", f[0, 4], f[1, 1], "m",
          f[1, 2], "m", f[1, 3], "m", f[1, 4], f[2, 1], "m", f[2, 2], "m",
          f[2, 3], "m", f[2, 4], f[3, 1], "m", f[3, 2], "m", f[3, 3], "m",
          f[3, 4], f[4, 1], "m", f[4, 2], "m", f[4, 3], "m", f[4, 4]*)






          share|improve this answer




















          • Perfect. Thanks.
            – Richard Burke-Ward
            1 hour ago












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          Map Riffle to each of the element of actualTable:



           desiredtable = Riffle[#, "m"] & /@ actualtable


          (* f[0, 1], "m", f[0, 2], "m", f[0, 3], "m", f[0, 4], f[1, 1], "m",
          f[1, 2], "m", f[1, 3], "m", f[1, 4], f[2, 1], "m", f[2, 2], "m",
          f[2, 3], "m", f[2, 4], f[3, 1], "m", f[3, 2], "m", f[3, 3], "m",
          f[3, 4], f[4, 1], "m", f[4, 2], "m", f[4, 3], "m", f[4, 4]*)






          share|improve this answer












          Map Riffle to each of the element of actualTable:



           desiredtable = Riffle[#, "m"] & /@ actualtable


          (* f[0, 1], "m", f[0, 2], "m", f[0, 3], "m", f[0, 4], f[1, 1], "m",
          f[1, 2], "m", f[1, 3], "m", f[1, 4], f[2, 1], "m", f[2, 2], "m",
          f[2, 3], "m", f[2, 4], f[3, 1], "m", f[3, 2], "m", f[3, 3], "m",
          f[3, 4], f[4, 1], "m", f[4, 2], "m", f[4, 3], "m", f[4, 4]*)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          FredrikD

          5071521




          5071521











          • Perfect. Thanks.
            – Richard Burke-Ward
            1 hour ago
















          • Perfect. Thanks.
            – Richard Burke-Ward
            1 hour ago















          Perfect. Thanks.
          – Richard Burke-Ward
          1 hour ago




          Perfect. Thanks.
          – Richard Burke-Ward
          1 hour ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181995%2fcombine-table-with-riffle%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery