Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,17 +0,0 @@
|
|||
with Ada.Text_IO, Ada.Command_Line; use Ada.Command_Line;
|
||||
|
||||
procedure Comma_Quibble is
|
||||
|
||||
begin
|
||||
case Argument_Count is
|
||||
when 0 => Ada.Text_IO.Put_Line("{}");
|
||||
when 1 => Ada.Text_IO.Put_Line("{" & Argument(1) & "}");
|
||||
when others =>
|
||||
Ada.Text_IO.Put("{");
|
||||
for I in 1 .. Argument_Count-2 loop
|
||||
Ada.Text_IO.Put(Argument(I) & ", ");
|
||||
end loop;
|
||||
Ada.Text_IO.Put(Argument(Argument_Count-1) & " and " &
|
||||
Argument(Argument_Count) & "}");
|
||||
end case;
|
||||
end Comma_Quibble;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
quibble: $[sequence :block][
|
||||
if? 0 = size sequence
|
||||
-> return "{}"
|
||||
if 0 = size sequence
|
||||
-> return "{}"
|
||||
|
||||
if? 1 = size sequence
|
||||
-> return ~"{|sequence\0|}"
|
||||
if 1 = size sequence
|
||||
-> return ~"{|sequence\0|}"
|
||||
|
||||
last: pop 'sequence
|
||||
return ~« {|join.with: ", " sequence| and |last|}
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
>>SOURCE FORMAT IS FREE
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. comma-quibbling-test.
|
||||
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
FUNCTION comma-quibbling
|
||||
.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 strs-area.
|
||||
03 strs-len PIC 9.
|
||||
03 strs PIC X(5)
|
||||
OCCURS 0 TO 9 TIMES
|
||||
DEPENDING ON strs-len.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MOVE "ABC" TO strs (1)
|
||||
MOVE "DEF" TO strs (2)
|
||||
MOVE "G" TO strs (3)
|
||||
MOVE "H" TO strs (4)
|
||||
|
||||
PERFORM VARYING strs-len FROM 0 BY 1 UNTIL strs-len > 4
|
||||
DISPLAY FUNCTION comma-quibbling(strs-area)
|
||||
END-PERFORM
|
||||
.
|
||||
END PROGRAM comma-quibbling-test.
|
||||
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
FUNCTION-ID. comma-quibbling.
|
||||
|
||||
DATA DIVISION.
|
||||
LOCAL-STORAGE SECTION.
|
||||
01 i PIC 9.
|
||||
|
||||
01 num-extra-words PIC 9.
|
||||
|
||||
LINKAGE SECTION.
|
||||
01 strs-area.
|
||||
03 strs-len PIC 9.
|
||||
03 strs PIC X(5)
|
||||
OCCURS 0 TO 9 TIMES
|
||||
DEPENDING ON strs-len.
|
||||
|
||||
01 str PIC X(50).
|
||||
|
||||
PROCEDURE DIVISION USING strs-area RETURNING str.
|
||||
EVALUATE strs-len
|
||||
WHEN ZERO
|
||||
MOVE "{}" TO str
|
||||
GOBACK
|
||||
|
||||
WHEN 1
|
||||
MOVE FUNCTION CONCATENATE("{", FUNCTION TRIM(strs (1)), "}")
|
||||
TO str
|
||||
GOBACK
|
||||
END-EVALUATE
|
||||
|
||||
MOVE FUNCTION CONCATENATE(FUNCTION TRIM(strs (strs-len - 1)),
|
||||
" and ", FUNCTION TRIM(strs (strs-len)), "}")
|
||||
TO str
|
||||
|
||||
IF strs-len > 2
|
||||
SUBTRACT 2 FROM strs-len GIVING num-extra-words
|
||||
PERFORM VARYING i FROM num-extra-words BY -1 UNTIL i = 0
|
||||
MOVE FUNCTION CONCATENATE(FUNCTION TRIM(strs (i)), ", ", str)
|
||||
TO str
|
||||
END-PERFORM
|
||||
END-IF
|
||||
|
||||
MOVE FUNCTION CONCATENATE("{", str) TO str
|
||||
.
|
||||
END FUNCTION comma-quibbling.
|
||||
|
|
@ -2,13 +2,9 @@ func$ tolist s$ .
|
|||
s$[] = strsplit s$ " "
|
||||
r$ = "{"
|
||||
n = len s$[]
|
||||
for i = 1 to n - 2
|
||||
r$ &= s$[i] & ", "
|
||||
.
|
||||
for i = 1 to n - 2 : r$ &= s$[i] & ", "
|
||||
if n > 0
|
||||
if n > 1
|
||||
r$ &= s$[n - 1] & " and "
|
||||
.
|
||||
if n > 1 : r$ &= s$[n - 1] & " and "
|
||||
r$ &= s$[n]
|
||||
.
|
||||
r$ &= "}"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public extension QuibbleOp : Array<string>
|
|||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
Console.printLine(new string[] { }.quibble());
|
||||
Console.printLine(new string[] { "ABC" }.quibble());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public extension QuibbleOp : Array<string>
|
|||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
Console.printLine(new string[] { }.quibble());
|
||||
Console.printLine(new string[] { "ABC" }.quibble());
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
function Out-Quibble
|
||||
{
|
||||
[OutputType([string])]
|
||||
Param
|
||||
(
|
||||
# Zero or more strings.
|
||||
[Parameter(Mandatory=$false, Position=0)]
|
||||
[AllowEmptyString()]
|
||||
[string[]]
|
||||
$Text = ""
|
||||
)
|
||||
|
||||
# If not null or empty...
|
||||
if ($Text)
|
||||
{
|
||||
# Remove empty strings from the array.
|
||||
$text = "$Text".Split(" ", [StringSplitOptions]::RemoveEmptyEntries)
|
||||
}
|
||||
else
|
||||
{
|
||||
return "{}"
|
||||
}
|
||||
|
||||
# Build a format string.
|
||||
$outStr = ""
|
||||
for ($i = 0; $i -lt $text.Count; $i++)
|
||||
{
|
||||
$outStr += "{$i}, "
|
||||
}
|
||||
$outStr = $outStr.TrimEnd(", ")
|
||||
|
||||
# If more than one word, insert " and" at last comma position.
|
||||
if ($text.Count -gt 1)
|
||||
{
|
||||
$cIndex = $outStr.LastIndexOf(",")
|
||||
$outStr = $outStr.Remove($cIndex,1).Insert($cIndex," and")
|
||||
}
|
||||
|
||||
# Output the formatted string.
|
||||
"{" + $outStr -f $text + "}"
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
Out-Quibble
|
||||
Out-Quibble "ABC"
|
||||
Out-Quibble "ABC", "DEF"
|
||||
Out-Quibble "ABC", "DEF", "G", "H"
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
$file = @'
|
||||
|
||||
ABC
|
||||
ABC, DEF
|
||||
ABC, DEF, G, H
|
||||
'@ -split [Environment]::NewLine
|
||||
|
||||
foreach ($line in $file)
|
||||
{
|
||||
Out-Quibble -Text ($line -split ", ")
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
Rebol []
|
||||
|
||||
comma-quibbling: func [block] [
|
||||
rejoin [
|
||||
"^{"
|
||||
|
||||
to-string use [s] [
|
||||
s: copy block
|
||||
s: next s
|
||||
forskip s 2 [insert s either tail? next s [" and "] [", "]]
|
||||
s: head s
|
||||
]
|
||||
|
||||
"^}"
|
||||
]
|
||||
]
|
||||
|
||||
foreach t [[] [ABC] [ABC DEF] [ABC DEF G H]] [print comma-quibbling t]
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
Rebol []
|
||||
|
||||
; builds string instead of using an intermediate block
|
||||
|
||||
comma-quibbling: func [block /oxford /local s length] [
|
||||
length: length? block
|
||||
rejoin [
|
||||
"^{"
|
||||
|
||||
either length < 2 [to-string block] [
|
||||
s: to-string block/1
|
||||
for n 2 (length - 1) 1 [repend s [", " pick block n]]
|
||||
if all [oxford (length > 2)] [append s ","]
|
||||
repend s [" and " last block]
|
||||
]
|
||||
|
||||
"^}"
|
||||
]
|
||||
]
|
||||
|
||||
test: [[] [ABC] [ABC DEF] [ABC DEF G H]]
|
||||
foreach t test [print comma-quibbling t]
|
||||
print "Now with Oxford comma"
|
||||
foreach t test [print comma-quibbling/oxford t]
|
||||
|
|
@ -2,7 +2,5 @@ Tests ← {{}
|
|||
{"ABC"}
|
||||
{"ABC" "DEF"}
|
||||
{"ABC" "DEF" "G" "H"}}
|
||||
Jam ← ◇⊂◇⊂:□
|
||||
Quibble ← |1 ⟨""◌|°□⊢|Jam" and "°⊟|Quibble⊂⊃(□Jam", "°⊟↙2)(↘2)⟩↧3⧻.
|
||||
Wrap ← ⊂⊂"{" : "}" Quibble
|
||||
⍚(&pWrap) Tests
|
||||
Quibble ← |1 ⨬(⋅""|°□⊢|$"_ and _"°⊟|Quibble⊂⊃(□$"_, _"°⊟↙2)↘₂)↧3⧻.
|
||||
⍚(&p$"{_}"Quibble) Tests
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
Function Quibble(s)
|
||||
arr = Split(s,",")
|
||||
If s = "" Then
|
||||
Quibble = "{}"
|
||||
ElseIf UBound(arr) = 0 Then
|
||||
Quibble = "{" & arr(0) & "}"
|
||||
Else
|
||||
Quibble = "{"
|
||||
For i = 0 To UBound(arr)
|
||||
If i = UBound(arr) - 1 Then
|
||||
Quibble = Quibble & arr(i) & " and " & arr(i + 1) & "}"
|
||||
Exit For
|
||||
Else
|
||||
Quibble = Quibble & arr(i) & ", "
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End Function
|
||||
|
||||
WScript.StdOut.Write Quibble("")
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write Quibble("ABC")
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write Quibble("ABC,DEF")
|
||||
WScript.StdOut.WriteLine
|
||||
WScript.StdOut.Write Quibble("ABC,DEF,G,H")
|
||||
WScript.StdOut.WriteLine
|
||||
Loading…
Add table
Add a link
Reference in a new issue