Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's rather clunky to read each value one at a time, but it's natural in M- to read them all at once and then process each one. </p> <p>Here's a simple infrastructure I use all the time: </p> <pre><code>(* step one: get data *) data = Import["ideone_fM0rs.txt", "Lines"]; (* step two: ??? *) res = {}; Module[{value, result}, value = #; result = yourCodeHere[value]; AppendTo[res, result]; ]&amp; /@ data; (* step three: PROFIT! *) Export["out.txt", res, "Lines"]; </code></pre> <p>but see Jon McLoone on AppendTo vs Sow/Reap for large data sets: <a href="http://blog.wolfram.com/2011/12/07/10-tips-for-writing-fast-mathematica-code" rel="nofollow">http://blog.wolfram.com/2011/12/07/10-tips-for-writing-fast-mathematica-code</a>. </p> <p>Here's a variation with Sow/Reap for the times you'd like to collect values under various tags or categories or genuses or whatever:</p> <pre><code>data = Import["ideone_fM0rs.txt", "Lines"]; res = Reap[Module[{value, result, tag}, value = #; result = yourCodeHere[value]; tag = generateTag[value] Sow[result, tag]; ]&amp; /@ data, _, Rule][[2]]; Export["out.txt", res, "Lines"]; </code></pre> <p>It's tempting to roll all that up into a single awe-inspiring one-liner, but for maintainability I like to keep it unrolled with each step made explicit.</p> <p>Of course, yourCodeHere[value] could instead be many lines of well-commented code.</p> <p>Note: I downloaded your data to a local file <code>ideone_fM0rs.txt</code> using the download link at <a href="http://ideone.com/fM0rs" rel="nofollow">http://ideone.com/fM0rs</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload