Imprimindo dados no Mathematica

0

Eu tenho um problema em imprimir dados no Mathematica. Se a linha for longa por exemplo

S = 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Eu quero imprimir S no formulário primeiro cinco espaços vazios, depois colocar "#" então 66 espaços de S, em seguida, insira o próximo pedido novamente o mesmo. Este formulário deve estar no WordPad aberto como aqui

 "5 spaces empty"#1111111111"(66times)"111111
 "5 spaces empty"#1111111111"(66times)"111111
  .....

Felicidades,

    
por Pipe 29.12.2011 / 11:46

1 resposta

1

Você pode usar o seguinte código:

In[58]:=
S=1111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
1111111111111111111111111111111111111111111111111111;
StringPartition[s_,l_]:=Table[StringTake[s,{i,Min[i+l-1, 
StringLength[s]]}],{i,1,StringLength[s],l}];
fmts=Map[("     #"<>#<>"\r")&,StringPartition[ToString[S],66]];
(* Unfortunately the web software is ruining the formatting of the output, deleting the extra spaces I placed before the #, etc. *)
(* But if you fix all the things this web software broke when I pasted your result and then run this and check the output carefully you should see it is correct *)
FullForm[fmts]

Out[61]//FullForm=
List[
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #11111111111111111111111111111111\r"
]
    
por 30.12.2011 / 18:37