From: Arthur N. <ac...@ca...> - 2024-01-05 16:51:56
|
On Fri, 5 Jan 2024, Nasser M. Abbasi wrote: > I have list, which in the attached script I print on to the terminal using > > write M; > > Where M is the list. > > Sometimes it displays on the terminal on one line as expected. > sometimes it displays each entry in the list on separate line. > > Here is screen shot attached. > > I added > > off output; > linelength(1000); > > At the top of my script in order to only see explicit output > from the "write" command and nothing else as the script runs. > > But I still see numbers 1: 2: 3: etc... print at the start of the > script. why is that? > > Please see the script file.red attached. > > I run it as follows > > redcsl < file.red > > I am using Reduce (CSL, rev 6657), 10-Dec-2023 on Linux > which I build from source code. (Thanks to Francis Wright for > sending me link to the source tar file as it was not easy to > find it at sourceforge). > > What do I need to change in the script so each list is printed > on one line, no matter how long it is? > > Thanks > --Nasser > If you drill down you will find the following code... put('list,'prifn,'listpri); symbolic procedure listpri l; % This definition is basically that of INPRINT, except that it % decides when to split at the comma by looking at the size of % the argument. begin scalar orig,split,u; u := l; l := cdr l; prin2!* get('!*lcbkt!*,'prtch); % Do it this way so table can change. orig := orig!*; orig!* := if posn!*<18 then posn!* else orig!*+3; if null l then go to b; split := treesizep(l,40); % 40 is arbitrary choice. a: maprint(negnumberchk car l,0); l := cdr l; if null l then go to b; oprin '!*comma!*; if split then terpri!* t; % <<<<<<<<<<<<< go to a; b: prin2!* get('!*rcbkt!*,'prtch); % terpri!* nil; orig!* := orig; return u end; and who put that in or last edited it is hard to tell, but I note the general copyright notice on the file gives the year as 1987 - so you may have some trouble. However when I dig back I find that magic code in Reeduce 3.3 files from 1987... So the answer is basically that back then output was to terminals and line printers for inspection and grossly over-long lines were not viewed as helpful, and that is a HACK that back then made the system nicer for general users. Since output that has super-long lines can not be viewed as human readable I would tend not to fuss about the line breaks. But if I did I could just enter a copy of the above code with the "split" related lines removed. And ask very politely if the maintainers would consider adding a flag that says "off splitverylonglists;" by putting an "if !*splitverylonglists then" in front of those few lines. The excess prompts are because you are piping input in via stdin, so each line is seen as a fresh input line deserving a prompt. The use of "in" to read a file or for the csl version going "redcsl inputfile.red" (note without any "<") may make life feel better. I offer a slightly reworked file.red for your delight... This shows that when one becomes a Reduce expert all sorts of specialist facilities become available. But these are aimed mainly at people who are implementing bodies of code to support new sorts of algebra etc (or indeed who are writing more or less elaborate test scripts). You keep mentioning Maple and Mathematica - I use neither of which and I do not have a budget to purchase expensive software! Eg the Maple Personal license at £221 may not be used for academic or non-profit use. I am not a student and anyway the cheaper student license prohibits use for research. So I would need to look at the Academic Single User license at £970. It looks as if Mathematica starts at £155 per year for online access or their most popular option is at £318 or £160 per year. Well actually for Mathematica my best option is to but a Raspberry Pi... not as fast and less memory than my main machine has but cheaper! But then compare and observe that Reduce is Open Source under about as permissive license as you can find. You can easily fetch all the sources if you need to build that way by pointing subversion at sourceforge, but there are (irregular) snapshots both of binaries for Windows, Linux and Mac and source. As to documentation, we do not have a cluster of hired documentation maintainance people, so I hope people will accept that the 1200 pages of manual that we have represents some work having been done on that. My feeling is that at that size it is hideously hard to find things just because there is so much. But I do not know how to deal with that challenge. Open source has some strengths but also weaknesses. A strength is that unlike the situation with the commercial offerings anybody can inspect all the code to find what capabilities are available, and the test/demo scripts (files with names of the form *.tst" and their associated *.rlg logs) illustrate facilities in ways that can be much more concrete than the manual. And comments in the source code may sometimes be the nearest to the manual that bits of documentation have got. Obviously the matching downside is that the full explanation is to be taken to include all that source code which is hard to get into and amazingly bulky, and that without a room full of people paid to refine documentation and user interface things develop based on perceived demand. With the sort of demand that causes an individual to take things into their own hands the strongest driver. So without doubt Reduce does not have document processing, graphing and publication facilities like the commercial offerings, nor a notebook-style GUI etc. SOME of its algebraic capabilities are a decent match for the rest of the field, we believe that some win but others represent technology from perhaps decades ago. The extent to which that matters depends critically on the particular problem you are trying to solve! If we do well we do well. If we do not then it is open to anybody to contribute enhancements, and they have the capability of making changes as deep inside the system as they need to. But being a stingy person without a body that funds my activity I still feel happy where I am.... off output; %load_package "algint"; % only try if actually needed! off nat; linelength(1000); % The fact that I have the following bunch of "symbolic operator" % statements points to this code wanting to do things rather % different from casual users, and that the code wants to use % various system-level facilities and it really therefore % wants to be coded in symbolic mode where there is finer % control over everything. symbolic operator time; symbolic operator printf; symbolic operator bldmsg; symbolic operator flatsizec; symbolic operator concat; COMMENT These are integration problems to solve; A := { % A list is nicer than a matrix I think {sin(x), x}, {1/(x^12+x^2), x}, {1/x*cos(x)*(1+x)^2+tan(x)*exp(x), x}, {sin(x)*exp(x), x}, {cos(x)*(1+x), x}, {1/(x^4+1), x}, {cos(x)*(1+x)^2+tan(x)*exp(x), x} }; COMMENT M is list which holds result for each integral. This is description of each entry in the list item 1 integer. The integral number item 2 integer. 1 or 0 depending is solved or not item 3 integer. leaf size of antiderivative. 0 if failed. item 4 integer. place holder. Put 0 for now. item 5 string representation of the CPU time. How long it took to do the integration. item 6 string. place holder. Put " " for now. item 7 string. The command used to do the integration as string. for example "int( sin(x),x)". item 8 string. The antiderivative produced in Latex. For now use " " until I figure out how to do this in Reduce item 9 string. Place holder. Use " " for now. item 10 integer. Place holder. Use 0 for now. item 11 string. The actual anti-derivative produced as string. Use " " for now until I figure out how to do this in Reduce item 12 string. Grade of anti-derivative. Use "B" for reduce. item 13 string. use " " for Reduce. item 14 integer. use 0 for Reduce. ; counter := 0; foreach p in A do begin scalar start_time, time_used, anti; % To limit the scope of these % How to set timelimit on int command? % Messy unless in symbolic mode % eg csl/cslbase/buildreduce.lsp uses limits for profiling runs. start_time := time(); anti := int(first p, second p); time_used := time() - start_time; M:={ % Repeatedly appending items one at a time looks clumsy. counter := counter+1, if freeof(anti, int) then 1 else 0, flatsizec anti, %field 3. 0, %field 4. Not used; time_used, %field 5. CPU time used """N/A""", %field 6. not used. bldmsg("""int(%@p, %@p)""", first p, second p), %field 7. command used. % Note bldmsg mostly for internal use so % a bit cryptic here, but does the job! """\\int \\,dx""", """N/A""", %field 9. Not used. Place holder 0, %field 10. Not used. Place holder bldmsg("""%@p""", anti), %field 11. actual antiderivative in double quotes. % Getting things in LaTeX form would be % feasible but is much deeper into symbolic % mode. """B""", %field 12. OK as is. use "B"; """N/A""", %field 13. OK as is. use "N/A"; 0}; %field 13. OK as is. printf("%@p", M); %display the row out "file.output"; printf("%@p%n", M); out t; % Send to the file end; end; ============================= Arthur |