Talk:Word wrap: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) (→REXX timings: lastpos and last versions) |
(→REXX timings: added reply to query, added a question. -- ~~~~.) |
||
Line 284: | Line 284: | ||
:: I refrained from using lastpos since the (classic?) Rexx on the host does not have it. Is version 2 that you refer to "my way" modified as noted above? Are your final versions 1 & 2 available somewhere? I had to look up vestigual (limited English) - it should have been vestigial:-) --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 06:35, 22 August 2013 (UTC) |
:: I refrained from using lastpos since the (classic?) Rexx on the host does not have it. Is version 2 that you refer to "my way" modified as noted above? Are your final versions 1 & 2 available somewhere? I had to look up vestigual (limited English) - it should have been vestigial:-) --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 06:35, 22 August 2013 (UTC) |
||
::: Are you sure about the '''lastpos''' BIF not being available in (your) host's version of REXX? It's been around in REXX at least since 1984 (according to a VM System Product Interpreter Reference Summary), long before it was ported to MVS (or whatever it's being called now). Which host (and release) are you using? I didn't post any of REXX version 2 programs since you signed your name to it, and I didn't want to publish various versions of it, as it would appear that you were the author, and it didn't seem worth all the bother to include disclaimers and whatnot, and I had so many versions. I was just fooling around and was squeezing blood from a turnip trying to get more performance out of the program. I probably could get more performance out of it, but I got tired shoveling all that coal, and I had to add more code to handle a special case of long words. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 07:28, 22 August 2013 (UTC) |
|||
<br>Here is the latest revision (with not much commenting, but better than nothing): |
|||
<lang rexx>/*rexx*/ parse arg ifid w /*get required options from CL */ |
|||
/*{timer}*/ parse arg ifid w times . /*a good try is 10k ──► 100k. */ |
|||
/*{timer}*/ if times=='' then times=1 /*use a default if omitted. */ |
|||
s='' |
|||
do while lines(ifid)\==0 |
|||
s=s linein(ifid) |
|||
end /*DO while*/ |
|||
s=space(s) /*remove superfluous blanks. */ |
|||
say 'length of input string:' length(s) /*display the length of input. */ |
|||
say |
|||
call time 'Reset' /*reset the REXX elapsed timer.*/ |
|||
/*{timer}*/ do jj=1 for times /*the repetitions thingy. */ |
|||
x=s' ' /*var X is destroyed (below).*/ |
|||
do while x\=='' /*1 chunk at a time.*/ |
|||
i=lastpos(' ',x,w+1) /*look for blank <W.*/ |
|||
if i==0 then do /*...no blank found.*/ |
|||
call o left(x,w) |
|||
parse var x =(w) x |
|||
end |
|||
else do /*... a blank found.*/ |
|||
call o left(x,i) |
|||
parse var x =(i) +1 x |
|||
end |
|||
end /*DO while*/ |
|||
/*{timer}*/ end /*jj*/ |
|||
say |
|||
say format(time('Elapsed'),,2) "seconds for" times 'times.' |
|||
call lineout ifid |
|||
exit |
|||
/*{timer}*/ o: if jj==times then say arg(1); return /*show last text*/ |
|||
o: say arg(1); return</lang> |
|||
Here is the input file: |
|||
<pre> |
|||
────────── Computer programming laws ────────── |
|||
The Primal Scenario -or- Basic Datum of Experience: |
|||
∙ Systems in general work poorly or not at all. |
|||
∙ Nothing complicated works. |
|||
∙ Complicated systems seldom exceed 5% efficiency. |
|||
∙ There is always a fly in the ointment. |
|||
</pre> |
|||
-- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 07:28, 22 August 2013 (UTC) |