Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1 +0,0 @@
type String is array (Positive range <>) of Character;

View file

@ -1 +0,0 @@
A (<first-index>..<last-index>)

View file

@ -1,14 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure Test_Slices is
Str : constant String := "abcdefgh";
N : constant := 2;
M : constant := 3;
begin
Put_Line (Str (Str'First + N - 1..Str'First + N + M - 2));
Put_Line (Str (Str'First + N - 1..Str'Last));
Put_Line (Str (Str'First..Str'Last - 1));
Put_Line (Head (Tail (Str, Str'Last - Index (Str, "d", 1)), M));
Put_Line (Head (Tail (Str, Str'Last - Index (Str, "de", 1) - 1), M));
end Test_Slices;

View file

@ -1,56 +0,0 @@
identification division.
program-id. substring.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 original.
05 value "this is a string".
01 starting pic 99 value 3.
01 width pic 99 value 8.
01 pos pic 99.
01 ender pic 99.
01 looking pic 99.
01 indicator pic x.
88 found value high-value when set to false is low-value.
01 look-for pic x(8).
procedure division.
substring-main.
display "Original |" original "|, n = " starting " m = " width
display original(starting : width)
display original(starting :)
display original(1 : length(original) - 1)
move "a" to look-for
move 1 to looking
perform find-position
if found
display original(pos : width)
end-if
move "is a st" to look-for
move length(trim(look-for)) to looking
perform find-position
if found
display original(pos : width)
end-if
goback.
find-position.
set found to false
compute ender = length(original) - looking
perform varying pos from 1 by 1 until pos > ender
if original(pos : looking) equal look-for then
set found to true
exit perform
end-if
end-perform
.
end program substring.

View file

@ -1,6 +1,6 @@
import extensions;
public program()
public Program()
{
var s := "0123456789";
var n := 3;
@ -8,9 +8,9 @@ public program()
var c := $51;
var z := "345";
console.writeLine(s.Substring(n, m));
console.writeLine(s.Substring(n, s.Length - n));
console.writeLine(s.Substring(0, s.Length - 1));
console.writeLine(s.Substring(s.indexOf(0, c), m));
console.writeLine(s.Substring(s.indexOf(0, z), m))
Console.writeLine(s.Substring(n, m));
Console.writeLine(s.Substring(n, s.Length - n));
Console.writeLine(s.Substring(0, s.Length - 1));
Console.writeLine(s.Substring(s.indexOf(0, c), m));
Console.writeLine(s.Substring(s.indexOf(0, z), m))
}

View file

@ -1,39 +0,0 @@
sequence baseString, subString, findString
integer findChar
integer m, n
baseString = "abcdefghijklmnopqrstuvwxyz"
-- starting from n characters in and of m length;
n = 12
m = 5
subString = baseString[n..n+m-1]
puts(1, subString )
puts(1,'\n')
-- starting from n characters in, up to the end of the string;
n = 12
subString = baseString[n..$]
puts(1, subString )
puts(1,'\n')
-- whole string minus last character;
subString = baseString[1..$-1]
puts(1, subString )
puts(1,'\n')
-- starting from a known character within the string and of m length;
findChar = 'o'
m = 5
n = find(findChar,baseString)
subString = baseString[n..n+m-1]
puts(1, subString )
puts(1,'\n')
-- starting from a known substring within the string and of m length.
findString = "pq"
m = 5
n = match(findString,baseString)
subString = baseString[n..n+m-1]
puts(1, subString )
puts(1,'\n')

View file

@ -1,23 +0,0 @@
# test string
$s = "abcdefgh"
# test parameters
$n, $m, $c, $s2 = 2, 3, [char]'d', $s2 = 'cd'
# starting from n characters in and of m length
# n = 2, m = 3
$s.Substring($n-1, $m) # returns 'bcd'
# starting from n characters in, up to the end of the string
# n = 2
$s.Substring($n-1) # returns 'bcdefgh'
# whole string minus last character
$s.Substring(0, $s.Length - 1) # returns 'abcdefg'
# starting from a known character within the string and of m length
# c = 'd', m =3
$s.Substring($s.IndexOf($c), $m) # returns 'def'
# starting from a known substring within the string and of m length
# s2 = 'cd', m = 3
$s.Substring($s.IndexOf($s2), $m) # returns 'cde'

View file

@ -1,41 +0,0 @@
REBOL [
Title: "Retrieve Substring"
URL: http://rosettacode.org/wiki/Substring#REBOL
]
s: "abcdefgh" n: 2 m: 3 char: #"d" chars: "cd"
; Note that REBOL uses base-1 indexing. Strings are series values,
; just like blocks or lists so I can use the same words to manipulate
; them. All these examples use the 'copy' function against the 's'
; string with a particular offset as needed.
; For the fragment "copy/part skip s n - 1 m", read from right to
; left. First you have 'm', which we ignore for now. Then evaluate
; 'n - 1' (makes 1), to adjust the offset. Then 'skip' jumps from the
; start of the string by that offset. 'copy' starts copying from the
; new start position and the '/part' refinement limits the copy by 'm'
; characters.
print ["Starting from n, length m:"
copy/part skip s n - 1 m]
; It may be helpful to see the expression with optional parenthesis:
print ["Starting from n, length m (parens):"
(copy/part (skip s (n - 1)) m)]
; This example is much simpler, so hopefully it's easier to see how
; the string start is position for the copy:
print ["Starting from n to end of string:"
copy skip s n - 1]
print ["Whole string minus last character:"
copy/part s (length? s) - 1]
print ["Starting from known character, length m:"
copy/part find s char m]
print ["Starting from substring, length m:"
copy/part find s chars m]

View file

@ -1,12 +0,0 @@
let s = "ABCDEFGH"
let from = 2
let length = 3
Js.log2("Original string: ", s)
Js.log(Js.String.substrAtMost(~from, ~length, s))
Js.log(Js.String.substr(~from, s))
Js.log(Js.String.substrAtMost(~from=0, ~length=(Js.String2.length(s) - 1), s))
Js.log(Js.String.substrAtMost(~from=(Js.String.indexOf("B", s)), ~length, s))
Js.log(Js.String.substrAtMost(~from=(Js.String.indexOf("BC", s)), ~length, s))

View file

@ -1,16 +0,0 @@
s = "rosettacode.org"
'starting from n characters in and of m length
WScript.StdOut.WriteLine Mid(s,8,4)
'starting from n characters in, up to the end of the string
WScript.StdOut.WriteLine Mid(s,8,Len(s)-7)
'whole string minus last character
WScript.StdOut.WriteLine Mid(s,1,Len(s)-1)
'starting from a known character within the string and of m length
WScript.StdOut.WriteLine Mid(s,InStr(1,s,"c"),4)
'starting from a known substring within the string and of m length
WScript.StdOut.WriteLine Mid(s,InStr(1,s,"ose"),6)