Long names are doom ?
00001111
00001111 at my-deja.net
Fri Jun 1 19:09:30 EDT 2001
00001111 wrote:
> Hi All,
>
> Anybody use variables/names longer than 31 character
> and finds it really useful ?
Christian Brolin (comp.lang.functional) wrote the program
which abbreviates identifiers.
In fact if you look deeply you start to smile.
This definitely is not human respond on these 3 initial claims but
Computer's one where even 'cyber brain' laughs full of irony.
Christian Brolin (comp.lang.functional) wrote:
>
> I have a program that can abbreviate names, e.g.:
>
> [(len,abbreviate len "Anybody_use_names_longer_than_31_characters")
> | len <- [43,42..10]];
> [(43, "Anybody_use_names_longer_than_31_characters"),
> (42, "Anybody_use_names_longer_than_31_charactrs"),
> (41, "Anybody_use_names_longer_than_31_charctrs"),
> (40, "Anybody_use_names_longer_than_31_chrctrs"),
> (39, "Anybody_use_names_longer_thn_31_chrctrs"),
> (38, "Anybody_use_names_longr_thn_31_chrctrs"),
> (37, "Anybody_use_names_lngr_thn_31_chrctrs"),
> (36, "Anybody_use_nams_lngr_thn_31_chrctrs"),
> (35, "Anybody_use_nms_lngr_thn_31_chrctrs"),
> (34, "Anybdy_use_nms_lngr_thn_31_chrctrs"),
> (33, "Anbdy_use_nms_lngr_thn_31_chrctrs"),
> (32, "Anbdy_us_nms_lngr_thn_31_chrctrs"),
> (31, "Anbd_us_nms_lngr_thn_31_chrctrs"),
> (30, "Anbd_us_nms_lngr_thn_31chrctrs"),
> (29, "Anbd_us_nms_lngr_thn31chrctrs"),
> (28, "Anbd_us_nms_lngrthn31chrctrs"),
> (27, "Anbd_us_nmslngrthn31chrctrs"),
> (26, "Anbd_usnmslngrthn31chrctrs"),
> (25, "Anbdusnmslngrthn31chrctrs"),
> (24, "Anbdusnmslngrthn31chrctr"),
> (23, "Anbdusnmslngrthn31chrct"),
> (22, "Anbdusnmslngrthn31chrc"),
> (21, "Anbdusnmslngrthn31chr"),
> (20, "Anbdusnmslngrthn31ch"),
> (19, "Anbdusnmslngrthn31c"),
> (18, "Anbdusnmslngrthn31"),
> (17, "Anbdusnmslngrthn3"),
> (16, "Anbdusnmslngrthn"),
> (15, "Anbdusnmslngrth"),
> (14, "Anbdusnmslngrt"),
> (13, "Anbdusnmslngr"),
> (12, "Anbdusnmslng"),
> (11, "Anbdusnmsln"),
> (10, "Anbdusnmsl")
>
>
Continuing little bit
(9,...)
(8,...)
(7,...)
(6,...)
(5,...)
(4,...)
(3,...)
(2,An)
(1,A)
(0, ERROR: FORTRAN NAME IS TOO SHORT.
CHOOSE IT BETWEEN 1 and 6 CHARACTERS. STOP. END)
Bravo Christian ! That's just real Classics!
Christian Brolin (comp.lang.functional) wrote:
>
>
>
>
>
>
>
> Code:
>
> abbreviate :: Int -> String -> String
> abbreviate maxlen
> = truncate
> . reverse
> . remove wordSeparators
> . remove allButFirstVowels
> . remove adjacentDuplicates
> . remove vowelsEmbeddedInConsonants
> . reverse
> where
> isVowel c = elem c "aeiouy"
> isConsonant c = isAlpha c && not (isVowel c)
> remove rule name = remove' (length name) rule name
> remove' _ _ [] = []
> remove' len rule name
> | len > maxlen = let (keep,del,test) = rule name
> in keep ++ remove' (len - del) rule test
> | otherwise = name
> vowelsEmbeddedInConsonants (f:e:d:rest)
> | isConsonant d && isVowel e && isConsonant f = ([f],1,d:rest)
> | otherwise = ([f],0,e:d:rest)
> vowelsEmbeddedInConsonants name = (name,0,[])
> adjacentDuplicates (e:d:rest)
> | d==e = ([],1,d:rest)
> | otherwise = ([e],0,d:rest)
> adjacentDuplicates name = (name,0,[])
> allButFirstVowels (e:d:rest)
> | isAlpha d && isVowel e = ([],1,d:rest)
> | otherwise = ([e],0,d:rest)
> allButFirstVowels name = (name,0,[])
> wordSeparators (u:rest)
> | u=='_' = ([],1,rest)
> | otherwise = ([u],0,rest)
> wordSeparators name = (name,0,[])
> truncate = take maxlen
>
> --
> Christian Brolin -> Det är fult att peka
> Then please respond why, where, when.
More information about the Python-list
mailing list