83 lines
4.9 KiB
Text
83 lines
4.9 KiB
Text
This task is an easier (to code) variant of the Rosetta Code task: <big> [[Abbreviations, simple]]</big>.
|
|
|
|
|
|
For this task, the following ''command table'' will be used:
|
|
Add ALTer BAckup Bottom CAppend Change SCHANGE CInsert CLAst COMPress COpy
|
|
COUnt COVerlay CURsor DELete CDelete Down DUPlicate Xedit EXPand EXTract Find
|
|
NFind NFINDUp NFUp CFind FINdup FUp FOrward GET Help HEXType Input POWerinput
|
|
Join SPlit SPLTJOIN LOAD Locate CLocate LOWercase UPPercase LPrefix MACRO
|
|
MErge MODify MOve MSG Next Overlay PARSE PREServe PURge PUT PUTD Query QUIT
|
|
READ RECover REFRESH RENum REPeat Replace CReplace RESet RESTore RGTLEFT
|
|
RIght LEft SAVE SET SHift SI SORT SOS STAck STATus TOP TRAnsfer Type Up
|
|
|
|
<!--
|
|
The unsorted list (above) was constructed to help ensure that program entries don't get tripped up by performing a left-to-right string comparison.
|
|
!-->
|
|
|
|
<!--
|
|
For the curious amongst you (and pack-rats of old publications, this is an old XEDIT command table; the sub-commands were extracted from:
|
|
Virtual Machine/
|
|
System Product
|
|
|
|
System Product
|
|
SP Editor
|
|
Command
|
|
Language
|
|
Reference
|
|
Summary
|
|
|
|
Release 4
|
|
|
|
SX24-5122-3
|
|
|
|
|
|
|
|
Fourth Edition (December 1984)
|
|
|
|
Information herein is extracted from
|
|
Virtual Machine/System Product System Product Editor Command and Macro Reference, SC24-5221.
|
|
|
|
|
|
This old version does not have some of the newer commands like QQuit and PQUIT, for instance,
|
|
and those commands that deal with DBCS (double-byte character set).
|
|
!-->
|
|
|
|
Notes concerning the above ''command table'':
|
|
::* it can be thought of as one long literal string (with blanks at end-of-lines)
|
|
::* it may have superfluous blanks
|
|
::* it may be in any case (lower/upper/mixed)
|
|
::* the order of the words in the ''command table'' must be preserved as shown
|
|
::* the user input(s) may be in any case (upper/lower/mixed)
|
|
::* commands will be restricted to the Latin alphabet (A ──► Z, a ──► z)
|
|
::* A valid abbreviation is a word that has:
|
|
:::* at least the minimum length of the number of capital letters of the word in the ''command table''
|
|
:::* compares equal (regardless of case) to the leading characters of the word in the ''command table''
|
|
:::* a length <u>not</u> longer than the word in the ''command table''
|
|
::::* '''ALT''', '''aLt''', '''ALTE''', and '''ALTER''' are all abbreviations of '''ALTer'''
|
|
::::* '''AL''', '''ALF''', '''ALTERS''', '''TER''', and '''A''' <u>aren't</u> valid abbreviations of '''ALTer'''
|
|
::::* The number of capital letters in '''ALTer''' indicates that any abbreviation for '''ALTer''' must be at least three letters
|
|
::::* Any word longer than five characters <u>can't</u> be an abbreviation for '''ALTer'''
|
|
::::* '''o''', '''ov''', '''oVe''', '''over''', '''overL''', '''overla''' are all acceptable abbreviations for '''Overlay'''
|
|
::* if there isn't any lowercase letters in the word in the ''command table'', then there isn't an abbreviation permitted
|
|
|
|
<!--
|
|
::* a Latin alphabet is used for this Rosetta Code task because it behaves well when letters are uppercased
|
|
!-->
|
|
|
|
;Task:
|
|
::* The command table needn't be verified/validated.
|
|
::* Write a function to validate if the user "words" (given as input) are valid (in the ''command table'').
|
|
::* If the word is valid, then return the full uppercase version of that "word".
|
|
::* If the word isn't valid, then return the lowercase string: <big> '''*error*''' </big> (7 characters).
|
|
::* A blank input (or a null input) should return a null string.
|
|
::* Show all output here.
|
|
|
|
|
|
;An example test case to be used for this task:
|
|
For a user string of:
|
|
riG rePEAT copies put mo rest types fup. 6 poweRin
|
|
the computer program should return the string:
|
|
RIGHT REPEAT *error* PUT MOVE RESTORE *error* *error* *error* POWERINPUT
|
|
|
|
{{Template:Strings}}
|
|
<br><br>
|