Vowel Density FIXED by rolf

/I (%stdin) (r) file def
/buf 100 string def 

/vowel
{
 /a exch def
 /ret false def
 (aeiouAEIOU) 
 {
   a eq { /ret true def } if
 }
 forall
 ret
} def

/stop false def
{
 I buf readline not {/stop true def} if
 /line exch def
 /sumv 0 def
 /sums 0 def
 line 
 {
  dup
  vowel { /sumv sumv 1 add def } if
  32 eq { /sums sums 1 add def } if 
 }
 forall
 /w sumv 40 mul line length sums sub idiv def
 w 0 eq
 {
  (*) =
 }
 {
  /out w string def
  0 1 w 1 sub { out exch 32 put } for
  out w 1 sub 42 put
  out =
 } ifelse  
 stop { exit } if
} loop

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page