2017-04-06 5 views
3

최소 동작하는 예제줄 바꿈없이 GAP의 텍스트 파일로 인쇄하는 방법은 무엇입니까?

x:=Indeterminate(Rationals,"x"); 
f:=Sum([1..1000],i->x^i); 
PrintTo("~/temp.txt",f); 

은 다음 temp.txt에 인쇄 :

x^1000+x^999+x^998+x^997+x^996+x^995+x^994+x^993+x^992+x^991+x^990+x^989+x^988\ 
+x^987+x^986+x^985+x^984+x^983+x^982+x^981+x^980+x^979+x^978+x^977+x^976+x^975\ 
+x^974+x^973+x^972+x^971+x^970+x^969+x^968+x^967+x^966+x^965+x^964+x^963+x^962\ 
+x^961+x^960+x^959+x^958+x^957+x^956+x^955+x^954+x^953+x^952+x^951+x^950+x^949\ 

[snip] 

어떻게 대신 텍스트 파일에서 한 줄에 인쇄 할 수 있습니까?

답변

2

일반적인 요구 사항이며 해결책은 SetPrintFormattingStatus입니다. 설명서를 보려면 its documentation online 을 보거나 GAP 프롬프트에 ?SetPrintFormattingStatus을 입력하기 만하면됩니다.

이 경우 스트림을 사용해야하며 텍스트 파일의 경우에는 이 제대로 작동하지 않습니다. OutputTextFile ( SetPrintFormattingStatus)이 필요합니다. 위의 예에서

x:=Indeterminate(Rationals,"x"); 
f:=Sum([1..1000],i->x^i); 
output := OutputTextFile("poly", false);; 
SetPrintFormattingStatus(output, false); 
PrintTo(output,f); 
를 사용