Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
21
Task/Tokenize-a-string/Ada/tokenize-a-string.adb
Normal file
21
Task/Tokenize-a-string/Ada/tokenize-a-string.adb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
with Ada.Text_IO, Ada.Containers.Indefinite_Vectors, Ada.Strings.Fixed, Ada.Strings.Maps;
|
||||
use Ada.Text_IO, Ada.Containers, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps;
|
||||
|
||||
procedure Tokenize is
|
||||
package String_Vectors is new Indefinite_Vectors (Positive, String);
|
||||
use String_Vectors;
|
||||
Input : String := "Hello,How,Are,You,Today";
|
||||
Start : Positive := Input'First;
|
||||
Finish : Natural := 0;
|
||||
Output : Vector := Empty_Vector;
|
||||
begin
|
||||
while Start <= Input'Last loop
|
||||
Find_Token (Input, To_Set (','), Start, Outside, Start, Finish);
|
||||
exit when Start > Finish;
|
||||
Output.Append (Input (Start .. Finish));
|
||||
Start := Finish + 1;
|
||||
end loop;
|
||||
for S of Output loop
|
||||
Put (S & ".");
|
||||
end loop;
|
||||
end Tokenize;
|
||||
11
Task/Tokenize-a-string/Ballerina/tokenize-a-string.ballerina
Normal file
11
Task/Tokenize-a-string/Ballerina/tokenize-a-string.ballerina
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import ballerina/io;
|
||||
import ballerina/regex;
|
||||
|
||||
public function main() {
|
||||
string s = "Hello,How,Are,You,Today";
|
||||
string[] oList = regex:split(s, ",");
|
||||
foreach string i in oList {
|
||||
io:print(i,".");
|
||||
}
|
||||
io:println();
|
||||
}
|
||||
30
Task/Tokenize-a-string/COBOL/tokenize-a-string.cob
Normal file
30
Task/Tokenize-a-string/COBOL/tokenize-a-string.cob
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
identification division.
|
||||
program-id. tokenize.
|
||||
|
||||
environment division.
|
||||
configuration section.
|
||||
repository.
|
||||
function all intrinsic.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 period constant as ".".
|
||||
01 cmma constant as ",".
|
||||
|
||||
01 start-with.
|
||||
05 value "Hello,How,Are,You,Today".
|
||||
|
||||
01 items.
|
||||
05 item pic x(6) occurs 5 times.
|
||||
|
||||
procedure division.
|
||||
tokenize-main.
|
||||
unstring start-with delimited by cmma
|
||||
into item(1) item(2) item(3) item(4) item(5)
|
||||
|
||||
display trim(item(1)) period trim(item(2)) period
|
||||
trim(item(3)) period trim(item(4)) period
|
||||
trim(item(5))
|
||||
|
||||
goback.
|
||||
end program tokenize.
|
||||
22
Task/Tokenize-a-string/Euphoria/tokenize-a-string.eu
Normal file
22
Task/Tokenize-a-string/Euphoria/tokenize-a-string.eu
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function split(sequence s, integer c)
|
||||
sequence out
|
||||
integer first, delim
|
||||
out = {}
|
||||
first = 1
|
||||
while first<=length(s) do
|
||||
delim = find_from(c,s,first)
|
||||
if delim = 0 then
|
||||
delim = length(s)+1
|
||||
end if
|
||||
out = append(out,s[first..delim-1])
|
||||
first = delim + 1
|
||||
end while
|
||||
return out
|
||||
end function
|
||||
|
||||
sequence s
|
||||
s = split("Hello,How,Are,You,Today", ',')
|
||||
|
||||
for i = 1 to length(s) do
|
||||
puts(1, s[i] & ',')
|
||||
end for
|
||||
36
Task/Tokenize-a-string/LOLCODE/tokenize-a-string.lol
Normal file
36
Task/Tokenize-a-string/LOLCODE/tokenize-a-string.lol
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
HAI 1.4
|
||||
|
||||
CAN HAS STRING?
|
||||
|
||||
HOW IZ I TOKENIZE YR S
|
||||
I HAS A L ITZ STRING IZ LEN YR S MKAY
|
||||
I HAS A WORDZ ITZ A BUKKIT
|
||||
I HAS A WORDCOUNT ITZ 0
|
||||
I HAS A C ITZ ""
|
||||
IM IN YR LOOP UPPIN YR N TIL BOTH SAEM N AN L
|
||||
I HAS A CN ITZ STRING IZ AT YR S AN YR N MKAY
|
||||
BOTH SAEM CN AN ",", O RLY?
|
||||
YA RLY
|
||||
WORDZ HAS A SRS WORDCOUNT ITZ C
|
||||
WORDCOUNT R SUM OF WORDCOUNT AN 1
|
||||
C R ""
|
||||
NO WAI, C R SMOOSH C CN MKAY
|
||||
OIC
|
||||
IM OUTTA YR LOOP
|
||||
WORDZ HAS A SRS WORDCOUNT ITZ C
|
||||
WORDCOUNT R SUM OF WORDCOUNT AN 1
|
||||
WORDZ HAS A LENGTH ITZ WORDCOUNT
|
||||
FOUND YR WORDZ
|
||||
IF U SAY SO
|
||||
|
||||
I HAS A TOKENZ ITZ I IZ TOKENIZE YR "Hello,How,Are,You,Today" MKAY
|
||||
|
||||
IM IN YR DISPLAY UPPIN YR N TIL BOTH SAEM N AN TOKENZ'Z LENGTH
|
||||
DIFFRINT N AN 0, O RLY?
|
||||
YA RLY, VISIBLE "."!
|
||||
OIC
|
||||
VISIBLE TOKENZ'Z SRS N!
|
||||
IM OUTTA YR DISPLAY
|
||||
VISIBLE ""
|
||||
|
||||
KTHXBYE
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$words = "Hello,How,Are,You,Today".Split(',')
|
||||
[string]::Join('.', $words)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$words = "Hello,How,Are,You,Today" -split ','
|
||||
$words -join '.'
|
||||
|
|
@ -0,0 +1 @@
|
|||
"Hello,How,Are,You,Today", ",,Hello,,Goodbye,," | ForEach-Object {($_.Split(',',[StringSplitOptions]::RemoveEmptyEntries)) -join "."}
|
||||
4
Task/Tokenize-a-string/Rebol/tokenize-a-string-1.rebol
Normal file
4
Task/Tokenize-a-string/Rebol/tokenize-a-string-1.rebol
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
print ["Original:" original: "Hello,How,Are,You,Today"]
|
||||
tokens: parse original ","
|
||||
dotted: "" repeat i tokens [append dotted rejoin [i "."]]
|
||||
print ["Dotted: " dotted]
|
||||
4
Task/Tokenize-a-string/Rebol/tokenize-a-string-2.rebol
Normal file
4
Task/Tokenize-a-string/Rebol/tokenize-a-string-2.rebol
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
print ["Original:" original: "Hello,How,Are,You,Today"]
|
||||
tokens: split original #","
|
||||
dotted: ajoin/with tokens #"."
|
||||
print ["Dotted: " dotted]
|
||||
4
Task/Tokenize-a-string/Rye/tokenize-a-string.rye
Normal file
4
Task/Tokenize-a-string/Rye/tokenize-a-string.rye
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
"Hello,How,Are,You,Today"
|
||||
|split ","
|
||||
|join\with "."
|
||||
|print
|
||||
2
Task/Tokenize-a-string/VBScript/tokenize-a-string.vbs
Normal file
2
Task/Tokenize-a-string/VBScript/tokenize-a-string.vbs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
s = "Hello,How,Are,You,Today"
|
||||
WScript.StdOut.Write Join(Split(s,","),".")
|
||||
6
Task/Tokenize-a-string/YAMLScript/tokenize-a-string.ys
Normal file
6
Task/Tokenize-a-string/YAMLScript/tokenize-a-string.ys
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
!YS-v0
|
||||
|
||||
say: +
|
||||
'Hello,How,Are,You,Today'
|
||||
.split(/,/)
|
||||
.join('.')
|
||||
Loading…
Add table
Add a link
Reference in a new issue