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,11 +0,0 @@
with Accumulator;
with Ada.Text_IO; use Ada.Text_IO;
procedure Example is
package A is new Accumulator;
package B is new Accumulator;
begin
Put_Line (Integer'Image (A.The_Function (5)));
Put_Line (Integer'Image (B.The_Function (3)));
Put_Line (Float'Image (A.The_Function (2.3)));
end;

View file

@ -1,11 +0,0 @@
generic package Accumulator is
-- This Ada generic package represents an accumulator factory.
-- The required function is provided as The_Function.
-- The first call to The_Function sets the initial value.
-- (Marius Amado-Alves)
function The_Function (X : Integer) return Integer;
function The_Function (X : Integer) return Float;
function The_Function (X : Float) return Float;
end;

View file

@ -1,64 +0,0 @@
package body Accumulator is
-- The accumulator lives through three states. It is in Virgin_State
-- before any use of The_Function. It changes to Integer_State or
-- Float_State, according to the input type used. The accumulation is
-- memorized in variable I or F, according to the state. Float_State,
-- once reached, is never left. A Float output on an Integer_State is
-- simply a conversion, sans effect on state. (Marius Amado-Alves)
type State_T is (Virgin_State, Integer_State, Float_State);
State : State_T := Virgin_State;
I : Integer;
F : Float;
function The_Function (X : Float) return Float is
begin
case State is
when Virgin_State =>
State := Float_State;
F := X;
return F;
when Integer_State =>
State := Float_State;
F := Float (I) + X;
return F;
when Float_State =>
F := F + X;
return F;
end case;
end;
function The_Function (X : Integer) return Float is
begin
case State is
when Virgin_State =>
State := Integer_State;
I := X;
return Float (I);
when Integer_State =>
I := I + X;
return Float (I);
when Float_State =>
F := F + Float (X);
return F;
end case;
end;
function The_Function (X : Integer) return Integer is
begin
case State is
when Virgin_State =>
State := Integer_State;
I := X;
return I;
when Integer_State =>
I := I + X;
return I;
when Float_State =>
F := F + Float (X);
return Integer (F);
end case;
end;
end;

View file

@ -1,16 +1,16 @@
function(acc)
= (n => acc.append(n));
accumulator(n)
Accumulator(n)
= function(new Variable(n));
public program()
public Program()
{
var x := accumulator(1);
var x := Accumulator(1);
x(5);
var y := accumulator(3);
var y := Accumulator(3);
Console.write(x(2.3r))
}

View file

@ -1,4 +0,0 @@
function Get-Accumulator ([double]$Start)
{
{param([double]$Plus) return $script:Start += $Plus}.GetNewClosure()
}

View file

@ -1,3 +0,0 @@
$total = Get-Accumulator -Start 1
& $total -Plus 5.0 | Out-Null
& $total -Plus 2.3

View file

@ -1,11 +0,0 @@
make-acc-gen: func [start-val] [
use [state] [
state: start-val
func [value] [
state: state + value
]
]
]
gen: make-acc-gen 1
print gen 5 ;== 6
print gen 2.3 ;== 8.3

View file

@ -1,25 +0,0 @@
;; Define a generator function 'gen' with an optional refinement '/init'
;; - 'value' is a required number passed to the function
;; - '/init' is an optional refinement for initialization
gen: function/with [value [number!] /init] [
;; If '/init' refinement is used, initialize state and exit immediately
if init [
state: value ;; Set the initial state to the provided value
exit ;; Exit, so nothing else in the function is run
]
;; If not initializing, add 'value' to 'state'
state: state + value
;; The function returns the new state each call
][state: 0] ;; 'state' is a local variable, initialized once per definition (persistent closure)
;; Initialize the 'state' value of gen to 1 by calling it with '/init'
gen/init 1
;; Call gen with 5: Adds 5 to state and prints the result (should print 6)
print gen 5
;; Call gen with 2.3: Adds 2.3 to state and prints the result (should print 8.3)
print gen 2.3

View file

@ -1,10 +0,0 @@
class accumulator
dim A
public default function acc(x)
A = A + x
acc = A
end function
public property get accum
accum = A
end property
end class

View file

@ -1,8 +0,0 @@
dim a
set a = new accumulator
x = a( 1 )
a 5
dim b
set b = new accumulator
b 3
wscript.echo a(2.3)