Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,13 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,length(@)-1)
|
||||
say 'string first & last character removed =' substr(@,2,length(@)-2)
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
||||
/* ╔═══════════════════════════════════════════════════════╗
|
||||
║ However, the original string may be null or exactly ║
|
||||
║ one byte in length which will cause the BIFs to ║
|
||||
║ fail because of either zero or a negative length. ║
|
||||
╚═══════════════════════════════════════════════════════╝ */
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,max(0,length(@)-1))
|
||||
say 'string first & last character removed =' substr(@,2,max(0,length(@)-2))
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
|
||||
/* [↓] an easier to read version using a length variable.*/
|
||||
@ = 'abcdefghijk'
|
||||
L=length(@)
|
||||
say ' the original string =' @
|
||||
say 'string first character removed =' substr(@,2)
|
||||
say 'string last character removed =' left(@,max(0,L-1))
|
||||
say 'string first & last character removed =' substr(@,2,max(0,L-2))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
/*REXX program demonstrates removal of 1st/last/1st&last chars from a string. */
|
||||
@ = 'abcdefghijk'
|
||||
say ' the original string =' @
|
||||
|
||||
parse var @ 2 z
|
||||
say 'string first character removed =' z
|
||||
|
||||
m=length(@)-1
|
||||
parse var @ z +(m)
|
||||
say 'string last character removed =' z
|
||||
|
||||
n=length(@)-2
|
||||
parse var @ 2 z +(n)
|
||||
if n==0 then z= /*handle special case of a length of 2.*/
|
||||
say 'string first & last character removed =' z
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*REXX program to show removal of 1st/last/1st&last chars from a string.*/
|
||||
z = 'abcdefghijk'
|
||||
|
||||
say ' the original string =' z
|
||||
say 'string first character removed =' substr(z,2)
|
||||
say 'string last character removed =' left(z,length(z)-1)
|
||||
say 'string first & last character removed =' substr(z,2,length(z)-2)
|
||||
exit
|
||||
/* ┌───────────────────────────────────────────────┐
|
||||
│ however, the original string may be null, │
|
||||
│ or of insufficient length which may cause the │
|
||||
│ BIFs to fail (because of negative length). │
|
||||
└───────────────────────────────────────────────┘ */
|
||||
|
||||
say ' the original string =' z
|
||||
say 'string first character removed =' substr(z,2)
|
||||
say 'string last character removed =' left(z,max(0,length(z)-1))
|
||||
say 'string first & last character removed =' substr(z,2,max(0,length(z)-2))
|
||||
/*stick a fork in it,we're done.*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue