Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. strInp = OpenRead ["Test.in"];
  2. strOut = OpenWrite ["Test.out"];
  3.  
  4. While[(str=Read[strInp, Number) != EndOfFile,
  5.  
  6. out = yourprocess[str];
  7.  
  8. Write [strOut,out];
  9. ];
  10.  
  11. Close [strOut];
  12. Close [strInp];
  13.  
  14. (* Now show the output file *)
  15. FilePrint ["Test.out]
  16.  
  17. (* step one: get data *)
  18. data = Import["ideone_fM0rs.txt", "Lines"];
  19.  
  20. (* step two: ??? *)
  21. res = {};
  22. Module[{value, result},
  23. value = #;
  24. result = yourCodeHere[value];
  25. AppendTo[res, result];
  26. ]& /@ data;
  27.  
  28. (* step three: PROFIT! *)
  29. Export["out.txt", res, "Lines"];
  30.  
  31. data = Import["ideone_fM0rs.txt", "Lines"];
  32.  
  33. res = Reap[Module[{value, result, tag},
  34. value = #;
  35. result = yourCodeHere[value];
  36. tag = generateTag[value]
  37. Sow[result, tag];
  38. ]& /@ data, _, Rule][[2]];
  39.  
  40. Export["out.txt", res, "Lines"];
  41.  
  42. data = ReadList["Test.in", Number, RecordLists-> True];
  43.  
  44. vals = Import["http://ideone.com/fM0rs",
  45. "Table"] /. {aa_ /; ! NumberQ[aa] && FreeQ[aa, List], ___} :>
  46. Sequence[] /. {} :> Sequence[]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement