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,10 @@
|
|||
blsq ) "RosettaCode"[-
|
||||
"osettaCode"
|
||||
blsq ) "RosettaCode"-]
|
||||
'R
|
||||
blsq ) "RosettaCode"~]
|
||||
"RosettaCod"
|
||||
blsq ) "RosettaCode"[~
|
||||
'e
|
||||
blsq ) "RosettaCode"~-
|
||||
"osettaCod"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
iex(1)> str = "abcdefg"
|
||||
"abcdefg"
|
||||
iex(2)> String.slice(str, 1..-1)
|
||||
"bcdefg"
|
||||
iex(3)> String.slice(str, 0..-2)
|
||||
"abcdef"
|
||||
iex(4)> String.slice(str, 1..-2)
|
||||
"bcdef"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(progn
|
||||
(setq string "top and tail")
|
||||
(insert (format "%s\n" string) )
|
||||
(setq len (length string) )
|
||||
(insert (format "%s\n" (substring string 1) ))
|
||||
(insert (format "%s\n" (substring string 0 (1- len) )))
|
||||
(insert (format "%s\n" (substring string 1 (1- len) ))))
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
% Implemented by Arjun Sunel
|
||||
string:left("Hello", length("Hello")-1,$.). % To strip the word from the right by 1
|
||||
|
||||
string:right("Hello", length("Hello")-1,$.). % To strip the word from the left by 1
|
||||
|
||||
string:left(string:right("Hello", length("Hello")-1,$.), length("Hello")-2,$.). %To strip the word from both sides by 1.
|
||||
1> Str = "Hello".
|
||||
"Hello"
|
||||
2> string:sub_string(Str, 2). % To strip the string from the right by 1
|
||||
"ello"
|
||||
3> string:sub_string(Str, 1, length(Str)-1). % To strip the string from the left by 1
|
||||
"Hell"
|
||||
4> string:sub_string(Str, 2, length(Str)-1). % To strip the string from both sides by 1
|
||||
"ell"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
word = "knights"
|
||||
|
||||
main = do
|
||||
-- You can drop the first item
|
||||
-- using `tail`
|
||||
putStrLn (tail word)
|
||||
|
||||
-- The `init` function will drop
|
||||
-- the last item
|
||||
putStrLn (init word)
|
||||
|
||||
-- We can combine these two to drop
|
||||
-- the last and the first characters
|
||||
putStrLn (middle word)
|
||||
|
||||
-- You can combine functions using `.`,
|
||||
-- which is pronounced "compose" or "of"
|
||||
middle = init . tail
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$string = "top and tail"
|
||||
$string
|
||||
$string.Substring(1)
|
||||
$string.Substring(0, $string.Length - 1)
|
||||
$string.Substring(1, $string.Length - 2)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$string = "top and tail"
|
||||
$string
|
||||
$string[1..($string.Length - 1)] -join ""
|
||||
$string[0..($string.Length - 2)] -join ""
|
||||
$string[1..($string.Length - 2)] -join ""
|
||||
|
|
@ -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.*/
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Function TopNTail(s,mode)
|
||||
Select Case mode
|
||||
Case "top"
|
||||
TopNTail = Mid(s,2,Len(s)-1)
|
||||
Case "tail"
|
||||
TopNTail = Mid(s,1,Len(s)-1)
|
||||
Case "both"
|
||||
TopNTail = Mid(s,2,Len(s)-2)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
WScript.Echo "Top: UPRAISERS = " & TopNTail("UPRAISERS","top")
|
||||
WScript.Echo "Tail: UPRAISERS = " & TopNTail("UPRAISERS","tail")
|
||||
WScript.Echo "Both: UPRAISERS = " & TopNTail("UPRAISERS","both")
|
||||
Loading…
Add table
Add a link
Reference in a new issue