Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Search-a-list/REXX/search-a-list-1.rexx
Normal file
29
Task/Search-a-list/REXX/search-a-list-1.rexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*REXX program searches a collection of strings (an array of periodic table elements).*/
|
||||
hay.= /*initialize the haystack collection. */
|
||||
hay.1 = 'sodium'
|
||||
hay.2 = 'phosphorous'
|
||||
hay.3 = 'californium'
|
||||
hay.4 = 'copernicium'
|
||||
hay.5 = 'gold'
|
||||
hay.6 = 'thallium'
|
||||
hay.7 = 'carbon'
|
||||
hay.8 = 'silver'
|
||||
hay.9 = 'curium'
|
||||
hay.10 = 'copper'
|
||||
hay.11 = 'helium'
|
||||
hay.12 = 'sulfur'
|
||||
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
upper needle /*in case some people capitalize stuff.*/
|
||||
found=0 /*assume the needle isn't found yet. */
|
||||
|
||||
do j=1 while hay.j\=='' /*keep looking in the haystack. */
|
||||
_=hay.j; upper _ /*make it uppercase to be safe. */
|
||||
if _=needle then do; found=1 /*we've found the needle in haystack. */
|
||||
leave /* ··· and stop looking, of course. */
|
||||
end
|
||||
end /*j*/
|
||||
|
||||
if found then return j /*return the haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates the needle wasn't found. */
|
||||
34
Task/Search-a-list/REXX/search-a-list-2.rexx
Normal file
34
Task/Search-a-list/REXX/search-a-list-2.rexx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*REXX program searches a collection of strings (an array of periodic table elements).*/
|
||||
hay.0 = 1000 /*safely indicate highest item number. */
|
||||
hay.200 = 'Binilnilium'
|
||||
hay.98 = 'californium'
|
||||
hay.6 = 'carbon'
|
||||
hay.112 = 'copernicium'
|
||||
hay.29 = 'copper'
|
||||
hay.114 = 'flerovium'
|
||||
hay.79 = 'gold'
|
||||
hay.2 = 'helium'
|
||||
hay.1 = 'hydrogen'
|
||||
hay.82 = 'lead'
|
||||
hay.116 = 'livermorium'
|
||||
hay.15 = 'phosphorous'
|
||||
hay.47 = 'silver'
|
||||
hay.11 = 'sodium'
|
||||
hay.16 = 'sulfur'
|
||||
hay.81 = 'thallium'
|
||||
hay.92 = 'uranium'
|
||||
/* [↑] sorted by the element name. */
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
upper needle /*in case some people capitalize. */
|
||||
found=0 /*assume the needle isn't found (yet).*/
|
||||
|
||||
do j=1 for hay.0 /*start looking in haystack, item 1. */
|
||||
_=hay.j; upper _ /*make it uppercase just to be safe. */
|
||||
if _=needle then do; found=1 /*we've found the needle in haystack. */
|
||||
leave /* ··· and stop looking, of course. */
|
||||
end
|
||||
end /*j*/
|
||||
|
||||
if found then return j /*return the haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates the needle wasn't found. */
|
||||
29
Task/Search-a-list/REXX/search-a-list-3.rexx
Normal file
29
Task/Search-a-list/REXX/search-a-list-3.rexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*REXX program searches a collection of strings (an array of periodic table elements).*/
|
||||
hay.=0 /*initialize the haystack collection. */
|
||||
hay._sodium = 1
|
||||
hay._phosphorous = 1
|
||||
hay._californium = 1
|
||||
hay._copernicium = 1
|
||||
hay._gold = 1
|
||||
hay._thallium = 1
|
||||
hay._carbon = 1
|
||||
hay._silver = 1
|
||||
hay._copper = 1
|
||||
hay._helium = 1
|
||||
hay._sulfur = 1
|
||||
/*underscores (_) are used to NOT ... */
|
||||
/* ... conflict with variable names. */
|
||||
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
|
||||
Xneedle = '_'needle /*prefix an underscore (_) character. */
|
||||
upper Xneedle /*uppercase: how REXX stores them. */
|
||||
|
||||
/*alternative version of above: */
|
||||
/* Xneedle=translate('_'needle) */
|
||||
|
||||
found=hay.Xneedle /*this is it, it's found (or maybe not)*/
|
||||
|
||||
if found then return j /*return the haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates the needle wasn't found. */
|
||||
37
Task/Search-a-list/REXX/search-a-list-4.rexx
Normal file
37
Task/Search-a-list/REXX/search-a-list-4.rexx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*REXX program searches a collection of strings (an array of periodic table elements).*/
|
||||
/*───────────────names of the first 200 elements of the periodic table.─────────────*/
|
||||
_= 'hydrogen helium lithium beryllium boron carbon nitrogen oxygen fluorine neon sodium'
|
||||
_=_ 'magnesium aluminum silicon phosphorous sulfur chlorine argon potassium calcium'
|
||||
_=_ 'scandium titanium vanadium chromium manganese iron cobalt nickel copper zinc'
|
||||
_=_ 'gallium germanium arsenic selenium bromine krypton rubidium strontium yttrium'
|
||||
_=_ 'zirconium niobium molybdenum technetium ruthenium rhodium palladium silver cadmium'
|
||||
_=_ 'indium tin antimony tellurium iodine xenon cesium barium lanthanum cerium'
|
||||
_=_ 'praseodymium neodymium promethium samarium europium gadolinium terbium dysprosium'
|
||||
_=_ 'holmium erbium thulium ytterbium lutetium hafnium tantalum tungsten rhenium osmium'
|
||||
_=_ 'iridium platinum gold mercury thallium lead bismuth polonium astatine radon'
|
||||
_=_ 'francium radium actinium thorium protactinium uranium neptunium plutonium americium'
|
||||
_=_ 'curium berkelium californium einsteinium fermium mendelevium nobelium lawrencium'
|
||||
_=_ 'rutherfordium dubnium seaborgium bohrium hassium meitnerium darmstadtium'
|
||||
_=_ 'roentgenium copernicium nihonium flerovium moscovium livermorium tennessine'
|
||||
_=_ 'oganesson ununennium unbinilium unbiunium unbibium unbitrium unbiquadium'
|
||||
_=_ 'unbipentium unbihexium unbiseptium unbioctium unbiennium untrinilium untriunium'
|
||||
_=_ 'untribium untritrium untriquadium untripentium untrihexium untriseptium untrioctium'
|
||||
_=_ 'untriennium unquadnilium unquadunium unquadbium unquadtrium unquadquadium'
|
||||
_=_ 'unquadpentium unquadhexium unquadseptium unquadoctium unquadennium unpentnilium'
|
||||
_=_ 'unpentunium unpentbium unpenttrium unpentquadium unpentpentium unpenthexium'
|
||||
_=_ 'unpentseptium unpentoctium unpentennium unhexnilium unhexunium unhexbium unhextrium'
|
||||
_=_ 'unhexquadium unhexpentium unhexhexium unhexseptium unhexoctium unhexennium'
|
||||
_=_ 'unseptnilium unseptunium unseptbium unsepttrium unseptquadium unseptpentium'
|
||||
_=_ 'unsepthexium unseptseptium unseptoctium unseptennium unoctnilium unoctunium'
|
||||
_=_ 'unoctbium unocttrium unoctquadium unoctpentium unocthexium unoctseptium unoctoctium'
|
||||
_=_ 'unoctennium unennilium unennunium unennbium unenntrium unennquadium unennpentium'
|
||||
_=_ 'unennhexium unennseptium unennoctium unennennium binilnilium'
|
||||
|
||||
haystack= _ /*assign the elements ───► haystack. */
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
upper needle haystack /*in case some people capitalize stuff.*/
|
||||
idx= wordpos(needle, haystack) /*use REXX's BIF: WORDPOS */
|
||||
if idx\==0 then return idx /*return the haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates the needle wasn't found. */
|
||||
/*stick a fork in it, we're all done. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue