home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / rexx / 1455 < prev    next >
Encoding:
Text File  |  1993-01-05  |  2.4 KB  |  72 lines

  1. Newsgroups: comp.lang.rexx
  2. Path: sparky!uunet!csfb1!jbrock
  3. From: jbrock@csfb1.fir.fbc.com (John Brock)
  4. Subject: Re:      Lower-case alphabetic set
  5. Message-ID: <C0E55F.IK5@csfb1.fir.fbc.com>
  6. Sender: news@csfb1.fir.fbc.com (Usenet News Account)
  7. Reply-To: uunet!csfb1!jbrock
  8. Organization: First Boston Corporation
  9. References:  <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU> <C0CDCz.Co3@csfb1.fir.fbc.com>
  10. Date: Tue, 5 Jan 1993 17:12:50 GMT
  11. Lines: 59
  12.  
  13. In article <C0CDCz.Co3@csfb1.fir.fbc.com>, jbrock@csfb1.fir.fbc.com (John Brock) writes:
  14. |> In article <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU>,         Wan Hasan Abdullah <WAN@UTMJB.BITNET> writes:
  15. |> |> Hello netters!
  16. |> |> 
  17. |> |> I found that, there's a function to translate all words to upper case
  18. |> |> but I could'nt find in HELP REXX to form the words from upper case to
  19. |> |> lower case by using a function. Could anyone help me to solve this
  20. |> |> problem?
  21. |> |> 
  22. |> |> Thanks in advance.
  23. |> |> 
  24. |> |> -WAN-
  25. |> 
  26. |> How about:
  27. |> 
  28. |>   lowercase: procedure
  29. |>   return translate(arg(1), xrange(), translate(xrange()))
  30. |> 
  31. |> I like this because it is consise and generic.  It should work as it
  32. |> stands for any language, and it lets me avoid typing out all the upper
  33. |> and lower case letters by hand (which I think looks ugly, even though
  34. |> it's clearly more efficient to do it that way).
  35.  
  36. I'm responding to my own post, as there have been other posts
  37. expressing concern about this type of procedure translating
  38. non-alphabetic characters.
  39.  
  40. On my system at least, all non-alphabetic characters are unchanged by
  41. the translate function when used with only one argument.  If this isn't
  42. part of the language definition it ought to be!  In any case you could
  43. argue that if c ^== translate(c) for any character c, then c by
  44. definition has a distinct upper case form, and my lowercase function
  45. makes sense.
  46.  
  47. It even makes a certain kind of sense if translate is generalized
  48. (e.g., mapping a ==> b, b ==> c, and c ==> a), an long as it never maps
  49. two distinct characters to the same character.
  50.  
  51. Here is a procedure which checks which characters on a given system
  52. are affected by the translate function:
  53.  
  54.   x = xrange()
  55.   y = ""
  56.   
  57.   do i = 1 to length(x)
  58.     c = substr(x, i, 1)
  59.     if c ^== translate(c) then y = y || c
  60.     end
  61.   
  62.   say length(y) y
  63.  
  64. On my (VM/CMS) system this yields:
  65.  
  66.   26 abcdefghijklmnopqrstuvwxyz
  67.  
  68. -- 
  69. John Brock
  70. uunet!csfb1!jbrock
  71. jbrock@csfb1.fir.fbc.com
  72.