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,51 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
procedure Main is
procedure print_range(start : integer; stop : integer; step : integer) is
Num : Integer := start;
begin
Put("Range(" & start'Image & ", " & stop'image &
", " & step'image & ") => ");
if stop < start then
Put_Line("Error: stop must be no less than start!");
elsif step not in positive then
Put_Line("Error: increment must be greater than 0!");
elsif start = stop then
Put_Line(start'image);
else
while num <= stop loop
Put(num'Image);
num := num + step;
end loop;
New_Line;
end if;
end print_range;
type test_record is record
start : integer;
stop : integer;
step : integer;
comment : unbounded_string := null_unbounded_string;
end record;
tests : array(1..9) of test_record :=
( 1 => (-2, 2, 1, To_Unbounded_String("Normal")),
2 => (-2, 2, 0, To_Unbounded_String("Zero increment")),
3 => (-2, 2, -1, To_Unbounded_String("Increments away from stop value")),
4 => (-2, 2, 10, To_Unbounded_String("First increment is beyond stop value")),
5 => (2, -1, 1, To_Unbounded_String("Start more than stop: positive increment")),
6 => (2, 2, 1, To_Unbounded_String("Start equal stop: positive increment")),
7 => (2, 2, -1, To_Unbounded_String("Start equal stop: negative increment")),
8 => (2, 2, 0, To_Unbounded_String("Start equal stop: zero increment")),
9 => (0, 0, 0, To_Unbounded_String("Start equal stop equal zero: zero increment")));
begin
for test of tests loop
Put(Test.Comment); Put(" : ");
print_range(test.start, test.stop, test.step);
New_line;
end loop;
end Main;

View file

@ -1,18 +1,19 @@
print "start stop increment"
loop @[
neg 2 2 1
neg 2 2 0
neg 2 2 neg 1
neg 2 2 10
2 neg 2 1
2 2 1
2 2 neg 1
2 2 0
0 0 0 ]
[start stop increment] ->
0-2 2 1
0-2 2 0
0-2 2 0-1
0-2 2 10
2 0-2 1
2 2 1
2 2 0-1
2 2 0
0 0 0
] [start stop increment] ->
print [
pad ~"|start|" 2 pad ~"|stop|" 7 pad ~"|increment|" 7
pad "->" 9 try? -> @range.step: increment start stop
else -> "Error"
pad "->" 9
if throws? -> @range.step: increment start stop
-> "Error"
]

View file

@ -1,30 +0,0 @@
Rebol [
title: "Rosetta code: Loops/Wrong ranges"
file: %Loops-Wrong_ranges.r3
url: https://rosettacode.org/wiki/Loops/Wrong_ranges
needs: 3.0.0
]
make-range: function [start end step][
res: copy []
if zero? step [return none]
for i start end step [
append res i
]
]
foreach [start end step] [
-2 2 1 ;Normal
-2 2 0 ;Zero increment
-2 2 -1 ;Increments away from stop value
-2 2 10 ;First increment is beyond stop value
2 -2 1 ;Start more than stop: positive increment
2 2 1 ;Start equal stop: positive increment
2 2 -1 ;Start equal stop: negative increment
2 2 0 ;Start equal stop: zero increment
0 0 0 ;Start equal stop equal zero: zero incremen
][
;; Using format to pad numbers
prin format ["make-range" -3 -3 -3] reduce [start end step]
prin " ;== "
;; Output 'make-range' function result
probe make-range start end step
]