Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
17
Task/Binary-strings/Ada/binary-strings-1.adb
Normal file
17
Task/Binary-strings/Ada/binary-strings-1.adb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
declare
|
||||
Data : Storage_Array (1..20); -- Data created
|
||||
begin
|
||||
Data := (others => 0); -- Assign all zeros
|
||||
if Data = (1..10 => 0) then -- Compare with 10 zeros
|
||||
declare
|
||||
Copy : Storage_Array := Data; -- Copy Data
|
||||
begin
|
||||
if Data'Length = 0 then -- If empty
|
||||
...
|
||||
end if;
|
||||
end;
|
||||
end if;
|
||||
... Data & 1 ... -- The result is Data with byte 1 appended
|
||||
... Data & (1,2,3,4) ... -- The result is Data with bytes 1,2,3,4 appended
|
||||
... Data (3..5) ... -- The result the substring of Data from 3 to 5
|
||||
end; -- Data destructed
|
||||
3
Task/Binary-strings/Ada/binary-strings-2.adb
Normal file
3
Task/Binary-strings/Ada/binary-strings-2.adb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
type Octet is mod 2**8;
|
||||
for Octet'Size use 8;
|
||||
type Octet_String is array (Positive range <>) of Octet;
|
||||
4
Task/Binary-strings/Ada/binary-strings-3.adb
Normal file
4
Task/Binary-strings/Ada/binary-strings-3.adb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
with Interfaces; use Interfaces;
|
||||
...
|
||||
type Octet is new Interfaces.Unsigned_8;
|
||||
type Octet_String is array (Positive range <>) of Octet;
|
||||
36
Task/Binary-strings/Pluto/binary-strings.pluto
Normal file
36
Task/Binary-strings/Pluto/binary-strings.pluto
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
-- Create string.
|
||||
local s = "abc"
|
||||
|
||||
-- Destroy string (not really see notes above).
|
||||
s = nil
|
||||
|
||||
-- (Re)assignment.
|
||||
s = "def"
|
||||
|
||||
-- Comparison.
|
||||
local b = (s == "abc") -- false
|
||||
local c = (s <= "ghi") -- true
|
||||
|
||||
-- Cloning/copying.
|
||||
local t = s
|
||||
|
||||
-- Check if empty.
|
||||
s = ""
|
||||
b = (s != "") -- false
|
||||
b = (#s == 0) -- true
|
||||
|
||||
-- Append a byte.
|
||||
s ..= "b"
|
||||
|
||||
-- Extract a substring.
|
||||
s = "ghijkl"
|
||||
t = s:sub(2, 5) -- "hijk"
|
||||
|
||||
-- Replace a byte or string.
|
||||
s = "abracadabra"
|
||||
s = s:replace("a", "z") -- "zbrzczdzbrz"
|
||||
|
||||
-- Join strings.
|
||||
s = "abc"
|
||||
t = "def"
|
||||
local u = s .. t -- "abcdef"
|
||||
67
Task/Binary-strings/PowerShell/binary-strings.ps1
Normal file
67
Task/Binary-strings/PowerShell/binary-strings.ps1
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
Clear-Host
|
||||
|
||||
## String creation (which is string assignment):
|
||||
Write-Host "`nString creation (which is string assignment):" -ForegroundColor Cyan
|
||||
Write-Host '[string]$s = "Hello cruel world"' -ForegroundColor Yellow
|
||||
[string]$s = "Hello cruel world"
|
||||
|
||||
## String (or any variable) destruction:
|
||||
Write-Host "`nString (or any variable) destruction:" -ForegroundColor Cyan
|
||||
Write-Host 'Remove-Variable -Name s -Force' -ForegroundColor Yellow
|
||||
Remove-Variable -Name s -Force
|
||||
|
||||
## Now reassign the variable:
|
||||
Write-Host "`nNow reassign the variable:" -ForegroundColor Cyan
|
||||
Write-Host '[string]$s = "Hello cruel world"' -ForegroundColor Yellow
|
||||
[string]$s = "Hello cruel world"
|
||||
|
||||
Write-Host "`nString comparison -- default is case insensitive:" -ForegroundColor Cyan
|
||||
Write-Host '$s -eq "HELLO CRUEL WORLD"' -ForegroundColor Yellow
|
||||
$s -eq "HELLO CRUEL WORLD"
|
||||
Write-Host '$s -match "HELLO CRUEL WORLD"' -ForegroundColor Yellow
|
||||
$s -match "HELLO CRUEL WORLD"
|
||||
Write-Host '$s -cmatch "HELLO CRUEL WORLD"' -ForegroundColor Yellow
|
||||
$s -cmatch "HELLO CRUEL WORLD"
|
||||
|
||||
## Copy a string:
|
||||
Write-Host "`nCopy a string:" -ForegroundColor Cyan
|
||||
Write-Host '$t = $s' -ForegroundColor Yellow
|
||||
$t = $s
|
||||
|
||||
## Check if a string is empty:
|
||||
Write-Host "`nCheck if a string is empty:" -ForegroundColor Cyan
|
||||
Write-Host 'if ($s -eq "") {"String is empty."} else {"String = $s"}' -ForegroundColor Yellow
|
||||
if ($s -eq "") {"String is empty."} else {"String = $s"}
|
||||
|
||||
## Append a byte to a string:
|
||||
Write-Host "`nAppend a byte to a string:" -ForegroundColor Cyan
|
||||
Write-Host "`$s += [char]46`n`$s" -ForegroundColor Yellow
|
||||
$s += [char]46
|
||||
$s
|
||||
|
||||
## Extract (and display) substring from a string:
|
||||
Write-Host "`nExtract (and display) substring from a string:" -ForegroundColor Cyan
|
||||
Write-Host '"Is the world $($s.Substring($s.IndexOf("c"),5))?"' -ForegroundColor Yellow
|
||||
"Is the world $($s.Substring($s.IndexOf("c"),5))?"
|
||||
|
||||
## Replace every occurrence of a byte (or a string) in a string with another string:
|
||||
Write-Host "`nReplace every occurrence of a byte (or a string) in a string with another string:" -ForegroundColor Cyan
|
||||
Write-Host "`$t = `$s -replace `"cruel`", `"beautiful`"`n`$t" -ForegroundColor Yellow
|
||||
$t = $s -replace "cruel", "beautiful"
|
||||
$t
|
||||
|
||||
## Join strings:
|
||||
Write-Host "`nJoin strings [1]:" -ForegroundColor Cyan
|
||||
Write-Host '"Is the world $($s.Split()[1]) or $($t.Split()[1])?"' -ForegroundColor Yellow
|
||||
"Is the world $($s.Split()[1]) or $($t.Split()[1])?"
|
||||
Write-Host "`nJoin strings [2]:" -ForegroundColor Cyan
|
||||
Write-Host '"{0} or {1}... I don''t care." -f (Get-Culture).TextInfo.ToTitleCase($s.Split()[1]), $t.Split()[1]' -ForegroundColor Yellow
|
||||
"{0} or {1}... I don't care." -f (Get-Culture).TextInfo.ToTitleCase($s.Split()[1]), $t.Split()[1]
|
||||
Write-Host "`nJoin strings [3] (display an integer array using the -join operater):" -ForegroundColor Cyan
|
||||
Write-Host '1..12 -join ", "' -ForegroundColor Yellow
|
||||
1..12 -join ", "
|
||||
|
||||
## Display an integer array in a tablular format:
|
||||
Write-Host "`nMore string madness... display an integer array in a tablular format:" -ForegroundColor Cyan
|
||||
Write-Host '1..12 | Format-Wide {$_.ToString().PadLeft(2)}-Column 3 -Force' -NoNewline -ForegroundColor Yellow
|
||||
1..12 | Format-Wide {$_.ToString().PadLeft(2)} -Column 3 -Force
|
||||
25
Task/Binary-strings/Rebol/binary-strings.rebol
Normal file
25
Task/Binary-strings/Rebol/binary-strings.rebol
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
;; String creation and destruction
|
||||
str: make string! 5
|
||||
str: none
|
||||
;; String assignment
|
||||
str: "Hello"
|
||||
;; String comparison
|
||||
str == "Hello" ;; case sensitive
|
||||
str = "hello" ;; case insensitive
|
||||
;; String cloning and copying
|
||||
tmp: copy str
|
||||
;; Check if a string is empty
|
||||
empty? tmp
|
||||
clear tmp
|
||||
empty? tmp
|
||||
;; Append a byte to a string
|
||||
append tmp "x" ;== "x"
|
||||
append/dup tmp "y" 2 ;== "xyy"
|
||||
;; Extract a substring from a string
|
||||
copy/part next tmp 2 ;== "yy"
|
||||
;; Replace every occurrence of a byte (or a string) in a string with another string
|
||||
replace/all str "l" "L"
|
||||
;; Join strings
|
||||
join str tmp
|
||||
rejoin [str space tmp]
|
||||
ajoin [str space tmp]
|
||||
Loading…
Add table
Add a link
Reference in a new issue