Rosetta Code/Rank languages by popularity: Difference between revisions

m
→‎REXX program: added/changed whitespace and comments.
m (→‎REXX program: added whitespace.)
m (→‎REXX program: added/changed whitespace and comments.)
Line 4,726:
call eSort #,1 /* " " along with members. */
call out /*create the RC_POP.OUT (output) file.*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _= insert(",",_,jc); end; return _
Line 4,741:
@= @.j; #= #.j; @.j= @.k; #.j= #.k; @.k= @; #.k= #
if h>=j then leave; j= j - h; k= k - h
end /*while #.k<#.j···*/
end /*i*/ /*hard swaps needed for embedded blanks.*/
end /*while h>1*/; return
Line 4,747:
get: langs= 0; call rdr 'languages' /*assign languages ───► L.ααα */
call rdr 'categories' /*append categories ───► catHeap */
#= 0
#=0; do j=1 until catHeap=='' /*process the heap of categories. */
parse var catHeap cat.j (sep) catHeap /*get a category from the catHeap. */
parse var cat.j cat.j '<' "(" mems . /*untangle the strange─looking string. */
Line 4,755 ⟶ 4,756:
if \datatype(mems, 'W') then iterate /*is the "members" number not numeric? */
#.0= #.0 + mems /*bump the number of members found. */
if u.?\==0 then do; do f=1 for # until ?==@u.f; end /*f*/
end /*f*/
#.f= #.f + mems; iterate j /*languages in different cases.*/
end /* [↑] handle any possible duplicates.*/
Line 4,761 ⟶ 4,763:
#.#= #.# + mems; @.#= cat.j; @u.#=? /*bump the counter; assign it (upper).*/
end /*j*/
 
!.=; @tno= '(total) number of' /*array holds indication of TIED langs.*/
call tell right(commas(#), 9) @tno 'languages detected in the category file'
call tell right(commas(langs),9) ' " " " " " " " language "'
call tell right(commas(#.0), 9) @tno 'entries (solutions) detected', , 1; term= 0
return /*don't show any more msgs──►term. [↑] */
/*──────────────────────────────────────────────────────────────────────────────────────*/
init: sep= '█'; L.=0; #.=0; u.=0#.; catHeap=; term=1; old.= /*assign some REXX vars*/
if catFID=='' then catFID= "RC_POP.CAT" /*Not specified? Then use the default.*/
if lanFID=='' then lanFID= "RC_POP.LAN" /* " " " " " " */
Line 4,783 ⟶ 4,786:
if which=='L' then inFID= lanFID /*use this fileID for the languages. */
if which=='C' then inFID= catFID /* " " " " " categories. */
Uyir= 'உயிர்/Uyir' /*Unicode (in text) name for Uyir */
old.10= '╬£C++' ; new.10= "µC++" /*Unicode ╬£C++ ───► ASCII─8: µC++ */
old.21= 'UC++' ; new.21= "µC++" /*old UC++ ───► ASCII─8: µC++ */
old.32= '╨£╨Ü-' ; new.32= "MK-" /*Unicode ╨£╨Ü─ ───► ASCII-8: MK- */
old.43= 'D├⌐j├á' ; new.43= "Déjà" /*Unicode ├⌐j├á ───► ASCII─8: Déjà */
old.54= 'Cach├⌐' ; new.54= "Caché" /*Unicode Cach├⌐ ───► ASCII─8: Caché */
old.65= '??-61/52' ; new.65= "MK-61/52" /*somewhere past, a mis─translated: MK-*/
old.76= 'F┼ìrmul├ª' ; new.76= 'Fôrmulæ' /*Unicode ───► ASCII─8: Fôrmulæ */
old.87= '╨£iniZinc' ; new.87= 'MiniZinc' /*Unicode ───► ASCII─8: MiniZinc*/
old.98= Uyir ; new.98= 'Uyir' /*Unicode ───► ASCII─8: Uyir */
old.109= 'Perl 6' ; new.109= 'Raku' /* (old name) ───► (new name) */
 
do recs=0 while lines(inFID) \== 0 /*read a file, a single line at a time.*/
$= translate( linein(inFID), , '9'x) /*handle any stray TAB ('09'x) chars.*/
$$= space($); if $$=='' then iterate /*ignore all blank lines in the file(s)*/
do v=10 while old.v \== '' /*translate Unicode variations of langs*/
if pos(old.v, $$) \==0 then $$= changestr(old.v, $$, new.v)
end /*v*/ /* [↑] handle different lang spellings*/
if igAst then do; igAst= pos(' * ', $)==0; if igAst then iterate; end
if pos('RETRIEVED FROM', translate($$))\==0 then leave /*pseudo End─Of─Data?.*/
if which=='L' then do; if left($$, 1)\=="*" then iterate /*lang ¬legitimate?*/
parse upper var $$ '*' $$ "<"; $$= space($$)
if $$=='' then iterate; /*recs*/; L.$$= 1
langs= langs +1 1 /*bump number of languages found. */
iterate /*recs*/ /*iterates the DO recs loop. */
end /* [↓] pickextract off thecomputer language name. */
if left($$, 1)=='*' then $$= sep || space( substr($$, 2) )
catHeap= catHeap $$ /*append to the catHeap (CATegory) heap*/