Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -0,0 +1,25 @@
100 DIM A$(3)
110 FOR TC=1 TO 4
120 : READ A: IF A=0 THEN 160
130 : FOR I=0 TO A-1
140 : READ A$(I)
150 : NEXT I
160 : GOSUB 200
170 : PRINT CQ$
180 NEXT TC
190 END
200 CQ$="["
210 IF A < 1 THEN 290
220 CQ$ = CQ$ + A$(0)
230 IF A < 2 THEN 290
240 IF A < 3 THEN 280
250 FOR I=1 TO A - 2
260 : CQ$ = CQ$ + ", " + A$(I)
270 NEXT I
280 CQ$ = CQ$ + " AND " + A$(A - 1)
290 CQ$ = CQ$ + "]"
300 RETURN
310 DATA 0
320 DATA 1, ABC
330 DATA 2, ABC, DEF
340 DATA 4, ABC, DEF, G, H

View file

@ -0,0 +1,32 @@
[(q)uibble: main entry point. print brackets, calling n in between if stack not
empty.]sx
[ [{]n z 0 !=n [}]pR ]sq
[(n)onempty: if more than 1 item, call m. then print top of stack.]sx
[ z 1 !=m n ]sn
[(m)ore: call f to flip stack into r register, call p to print most of it,
then pop the last item back onto the main stack so it's there to be printed
after we return]sx
[ lfx lpx Lr ]sm
[(f)lip: utility routine to reverse the stack into the r register]sx
[ Sr z 0 !=f ]sf
[(p)rint: get next item from stack in r register and print it. If there are
more than 2 items left on the register stack (which never drops below one
item), print a comma (c) and recurse. If there are exactly two items left,
print " and " (a) and return.]sx
[ Lr n 2 yr >c 2 yr =a 2 yr >p]sp
[(c)omma: utility routine to print a comma followed by a space]sx
[ [, ]n ]sc
[(a)and: utility routine to print " and "]sx
[ [ and ]n ]sa
[run tests]sx
lqx
[ABC] lqx
[ABC] [DEF] lqx
[ABC] [DEF] [G] [H] lqx

View file

@ -1,18 +1,21 @@
<?php
function quibble($arr){
function quibble($arr) {
$words = count($arr);
switch (count($arr)) {
if($words == 0){
return '{}';
}elseif($words == 1){
return '{'.$arr[0].'}';
}elseif($words == 2){
return '{'.$arr[0].' and '.$arr[1].'}';
}else{
return '{'.implode(', ', array_splice($arr, 0, -1) ). ' and '.$arr[0].'}';
}
case 0:
return '{}';
case 1:
return "{{$arr[0]}}";
default:
$left = implode(', ', array_slice($arr, 0, -1));
$right = array_slice($arr, -1)[0];
return "{{$left} and {$right}}";
}
}
@ -27,3 +30,4 @@ $tests = [
foreach ($tests as $test) {
echo quibble($test) . PHP_EOL;
}
?>

View file

@ -0,0 +1,15 @@
quibble() {
printf '{'
while (( $# > 2 )); do
printf '%s, ' "$1"
shift
done
if (( $# )); then
printf '%s' "$1"
shift
fi
if (( $# )); then
printf ' and %s' "$1"
fi
printf '%s\n' '}'
}

View file

@ -0,0 +1,15 @@
quibble() {
printf '{'
while [ $# -gt 2 ]; do
printf '%s, ' "$1"
shift
done
if [ $# -gt 0 ]; then
printf '%s' "$1"
shift
fi
if [ $# -gt 0 ]; then
printf ' and %s' "$1"
fi
printf '%s\n' '}'
}

View file

@ -0,0 +1,5 @@
quibble() {
printf '{'
if (( $# > 1 )) printf '%s and ' ${(j:, :)@[1,-2]}
printf '%s}\n' $@[-1]
}

View file

@ -0,0 +1,4 @@
quibble
quibble ABC
quibble ABC DEF
quibble ABC DEF G H

View file

@ -1,15 +0,0 @@
quibble() {
# Here awk(1) is easier than sed(1).
awk 'BEGIN {
for (i = 1; i < ARGC - 2; i++) s = s ARGV[i] ", "
i = ARGC - 2; if (i > 0) s = s ARGV[i] " and "
i = ARGC - 1; if (i > 0) s = s ARGV[i]
printf "{%s}\n", s
exit 0
}' "$@"
}
quibble
quibble ABC
quibble ABC DEF
quibble ABC DEF G H

View file

@ -0,0 +1,8 @@
Tests ← {{}
{"ABC"}
{"ABC" "DEF"}
{"ABC" "DEF" "G" "H"}}
Jam ← ◇⊂◇⊂:□
Quibble ← |1 ⟨""◌|°□⊢|Jam" and "°⊟|Quibble⊂⊃(□Jam", "°⊟↙2)(↘2)⟩↧3⧻.
Wrap ← ⊂⊂"{" : "}" Quibble
⍚(&pWrap) Tests