home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.rexx
- Path: sparky!uunet!csfb1!jbrock
- From: jbrock@csfb1.fir.fbc.com (John Brock)
- Subject: Re: Lower-case alphabetic set
- Message-ID: <C0E55F.IK5@csfb1.fir.fbc.com>
- Sender: news@csfb1.fir.fbc.com (Usenet News Account)
- Reply-To: uunet!csfb1!jbrock
- Organization: First Boston Corporation
- References: <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU> <C0CDCz.Co3@csfb1.fir.fbc.com>
- Date: Tue, 5 Jan 1993 17:12:50 GMT
- Lines: 59
-
- In article <C0CDCz.Co3@csfb1.fir.fbc.com>, jbrock@csfb1.fir.fbc.com (John Brock) writes:
- |> In article <REXXLIST%93010320580660@OHSTVMA.ACS.OHIO-STATE.EDU>, Wan Hasan Abdullah <WAN@UTMJB.BITNET> writes:
- |> |> Hello netters!
- |> |>
- |> |> I found that, there's a function to translate all words to upper case
- |> |> but I could'nt find in HELP REXX to form the words from upper case to
- |> |> lower case by using a function. Could anyone help me to solve this
- |> |> problem?
- |> |>
- |> |> Thanks in advance.
- |> |>
- |> |> -WAN-
- |>
- |> How about:
- |>
- |> lowercase: procedure
- |> return translate(arg(1), xrange(), translate(xrange()))
- |>
- |> I like this because it is consise and generic. It should work as it
- |> stands for any language, and it lets me avoid typing out all the upper
- |> and lower case letters by hand (which I think looks ugly, even though
- |> it's clearly more efficient to do it that way).
-
- I'm responding to my own post, as there have been other posts
- expressing concern about this type of procedure translating
- non-alphabetic characters.
-
- On my system at least, all non-alphabetic characters are unchanged by
- the translate function when used with only one argument. If this isn't
- part of the language definition it ought to be! In any case you could
- argue that if c ^== translate(c) for any character c, then c by
- definition has a distinct upper case form, and my lowercase function
- makes sense.
-
- It even makes a certain kind of sense if translate is generalized
- (e.g., mapping a ==> b, b ==> c, and c ==> a), an long as it never maps
- two distinct characters to the same character.
-
- Here is a procedure which checks which characters on a given system
- are affected by the translate function:
-
- x = xrange()
- y = ""
-
- do i = 1 to length(x)
- c = substr(x, i, 1)
- if c ^== translate(c) then y = y || c
- end
-
- say length(y) y
-
- On my (VM/CMS) system this yields:
-
- 26 abcdefghijklmnopqrstuvwxyz
-
- --
- John Brock
- uunet!csfb1!jbrock
- jbrock@csfb1.fir.fbc.com
-