new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
30
Task/Search-a-list/REXX/search-a-list-1.rexx
Normal file
30
Task/Search-a-list/REXX/search-a-list-1.rexx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*REXX program searches a collection of strings. */
|
||||
hay.= /*initialize 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.*/
|
||||
found=0 /*assume needle isn't found yet. */
|
||||
|
||||
do j=1 while hay.j\=='' /*keep looking in haystack. */
|
||||
_=hay.j; upper _ /*make it uppercase to be safe. */
|
||||
if _=needle then do /*we've found needle in haystack.*/
|
||||
found=1 /*indicate that needle was found,*/
|
||||
leave /* and stop looking, of course. */
|
||||
end
|
||||
end /*j*/
|
||||
|
||||
if found then return j /*return haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates needle wasn't found. */
|
||||
44
Task/Search-a-list/REXX/search-a-list-2.rexx
Normal file
44
Task/Search-a-list/REXX/search-a-list-2.rexx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*REXX program searches a collection of strings. */
|
||||
hay.0=1000 /*safely indicate highest item #.*/
|
||||
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'
|
||||
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
upper needle /*in case some people capitalize.*/
|
||||
found=0 /*assume needle isn't found, yet.*/
|
||||
|
||||
do j=1 for hay.0 /*start looking in haystack item1*/
|
||||
_=hay.j; upper _ /*make it uppercase to be safe. */
|
||||
if _=needle then do /*we've found needle in haystack.*/
|
||||
found=1 /*indicate that needle was found,*/
|
||||
leave /* and stop looking, of course. */
|
||||
end
|
||||
end /*j*/
|
||||
|
||||
if found then return j /*return haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates needle wasn't found. */
|
||||
|
||||
/*─────────────────────────────────────────────── incidentally, to find */
|
||||
/* the number of haystack items: */
|
||||
hayItems=0
|
||||
|
||||
do k=1 for hay.0 /*find item AFTER the last item.*/
|
||||
if hay.k\=='' then hayItems=hayItems+1 /*bump the item counter.*/
|
||||
end /*k*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
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. */
|
||||
hay.=0 /*initialize haystack collection.*/
|
||||
hay._sodium = 1
|
||||
hay._phosphorous = 1
|
||||
hay._califonium = 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 (_) char. */
|
||||
upper Xneedle /*uppercase: how REXX stores 'em.*/
|
||||
|
||||
/*alternative version of above, */
|
||||
/* Xneedle=translate('_'needle)*/
|
||||
|
||||
found=hay.Xneedle /*this is it, it's found or not.*/
|
||||
|
||||
if found then return j /*return haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates needle wasn't found. */
|
||||
24
Task/Search-a-list/REXX/search-a-list-4.rexx
Normal file
24
Task/Search-a-list/REXX/search-a-list-4.rexx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*REXX program searches a collection of strings. */
|
||||
|
||||
haystack=, /*names of the first 200 elements of the periodic table*/
|
||||
'hydrogen helium lithium berylliumbon nitrogen oxygen fluorine neon sodium magnesium aluminum silicon phosphorous sulfur chlorine argon potassium calcium scandium titanium',
|
||||
'vanadium chromium manganese iron kel copper zinc gallium germanium arsenic selenium bromine krypton rubidium strontium yttrium zirconium niobium molybdenum technetium ruthenium',
|
||||
'rhodium palladium silver cadmium antimony tellurium iodine xenon cesium barium lanthanum cerium praseodymium neodymium promethium samarium europium gadolinium terbium dysprosium',
|
||||
'holmium erbium thulium ytterbium afnium tantalum tungsten rhenium osmium irdium platinum gold mercury thallium lead bismuth polonium astatine radon francium radium actinium',
|
||||
'thorium protactinium uranium neptonium americium curium berkelium californium einsteinum fermium mendelevium nobelium lawrencium rutherfordium dubnium seaborgium bohrium hassium',
|
||||
'meitnerium darmstadtium roentgenicium ununtrium flerovium ununpentium livermorium ununseptium ununoctium ununennium unbinilium unbiunium unbibium unbitrium unbiquadium',
|
||||
'unbipentium unbihexium unbiseptiuum unbiennium untrinilium untriunium untribium untritrium untriquadium untripentium untrihexium untriseptium untrioctium untriennium unquadnilium',
|
||||
'unquadunium unquadbium unquadtriuadium unquadpentium unquadhexium unquadseptium unquadoctium unquadennium unpentnilium unpentunium unpentbium unpenttrium unpentquadium',
|
||||
'unpentpentium unpenthexium unpentpentoctium unpentennium unhexnilium unhexunium unhexbium unhextrium unhexquadium unhexpentium unhexhexium unhexseptium unhexoctium unhexennium',
|
||||
'unseptnilium unseptunium unseptbirium unseptquadium unseptpentium unsepthexium unseptseptium unseptoctium unseptennium unoctnilium unoctunium unoctbium unocttrium unoctquadium',
|
||||
'unoctpentium unocthexium unoctsepoctium unoctennium unennilium unennunium unennbium unenntrium unennquadium unennpentium unennhexium unennseptium unennoctium unennennium binilnilium'
|
||||
|
||||
needle = 'gold' /*we'll be looking for the gold. */
|
||||
|
||||
upper needle haystack /*in case some people capitalize.*/
|
||||
|
||||
idx=wordpos(needle,haystack) /*use REXX's bif: WORDPOS */
|
||||
/* bif: built-in function.*/
|
||||
if idx\==0 then return idx /*return haystack index number. */
|
||||
else say needle "wasn't found in the haystack!"
|
||||
return 0 /*indicates needle wasn't found. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue