Odd words: Difference between revisions
Content added Content deleted
(→{{header|FreeBASIC}}: -because we know this is likely coming) |
Walterpachl (talk | contribs) m (add REXX) |
||
Line 112: | Line 112: | ||
printf(1,"%d odd words found: %s\n",{length(res),join(shorten(res,"",3),", ")})</lang> |
printf(1,"%d odd words found: %s\n",{length(res),join(shorten(res,"",3),", ")})</lang> |
||
=={{header|REXX}}== |
|||
<lang rwxx>/* REXX */ |
|||
fid='d:\unix.txt' |
|||
ww.=0 /* ww.* the words to be analyzed */ |
|||
w.=0 /* w.word = 1 if word is in unix.txt */ |
|||
Do While lines(fid)>0 |
|||
l=linein(fid) /* a word */ |
|||
ll=length(l) |
|||
w.l=1 /* word is in unix.txt */ |
|||
If ll>=9 Then Do /* worth to be analyzed */ |
|||
z=ww.0+1 /* add it to the list */ |
|||
ww.z=l |
|||
ww.0=z |
|||
End |
|||
End |
|||
n=0 |
|||
Do i=1 To ww.0 |
|||
wodd=wodd(ww.i) |
|||
If w.wodd Then Do |
|||
n=n+1 |
|||
Say format(n,3) left(ww.i,10) wodd |
|||
End |
|||
End |
|||
Exit |
|||
wodd: Procedure |
|||
/* use odd indexed letters */ |
|||
Parse Arg w |
|||
wo='' |
|||
Do i=1 To length(w) |
|||
If i//2=1 Then |
|||
wo=wo||substr(w,i,1) |
|||
End |
|||
Return wo</lang> |
|||
{{out}} |
|||
<pre> 1 barbarian brain |
|||
2 childbear cider |
|||
3 corrigenda cried |
|||
4 gargantuan grata |
|||
5 headdress hades |
|||
6 palladian plain |
|||
7 propionate point |
|||
8 salvation slain |
|||
9 siltation slain |
|||
10 slingshot sight |
|||
11 statuette saute |
|||
12 supersede spree |
|||
13 supervene spree |
|||
14 terminable trial</pre> |
|||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
<lang ring> |
<lang ring> |