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,17 +0,0 @@
with Ada.Text_Io; use Ada.Text_Io;
procedure Subprogram_As_Argument is
type Proc_Access is access procedure;
procedure Second is
begin
Put_Line("Second Procedure");
end Second;
procedure First(Proc : Proc_Access) is
begin
Proc.all;
end First;
begin
First(Second'Access);
end Subprogram_As_Argument;

View file

@ -1,52 +0,0 @@
with Ada.Text_Io; use Ada.Text_Io;
procedure Subprogram_As_Argument_2 is
-- Definition of an access to long_float
type Lf_Access is access Long_Float;
-- Definition of a function returning Lf_Access taking an
-- integer as a parameter
function Func_To_Be_Passed(Item : Integer) return Lf_Access is
Result : Lf_Access := new Long_Float;
begin
Result.All := 3.14159 * Long_Float(Item);
return Result;
end Func_To_Be_Passed;
-- Definition of an access to function type matching the function
-- signature above
type Func_Access is access function(Item : Integer) return Lf_Access;
-- Definition of an integer access type
type Int_Access is access Integer;
-- Define a function taking an instance of Func_Access as its
-- parameter and returning an integer access type
function Complex_Func(Item : Func_Access; Parm2 : Integer) return Int_Access is
Result : Int_Access := new Integer;
begin
Result.All := Integer(Item(Parm2).all / 3.14149);
return Result;
end Complex_Func;
-- Declare an access variable to hold the access to the function
F_Ptr : Func_Access := Func_To_Be_Passed'access;
-- Declare an access to integer variable to hold the result
Int_Ptr : Int_Access;
begin
-- Call the function using the access variable
Int_Ptr := Complex_Func(F_Ptr, 3);
Put_Line(Integer'Image(Int_Ptr.All));
end Subprogram_As_Argument_2;

View file

@ -1,6 +1,6 @@
import extensions;
public program()
public Program()
{
var first := (f => f());
var second := { ^ "second" };

View file

@ -1,9 +0,0 @@
procedure use(integer fi, integer a, integer b)
print(1,call_func(fi,{a,b}))
end procedure
function add(integer a, integer b)
return a + b
end function
use(routine_id("add"),23,45)

View file

@ -1,5 +1,5 @@
(function prepend-hello s
(str "Hello, " s))
"Hello, {s}")
(function modify-string f s
(f s))

View file

@ -119,56 +119,58 @@ type
implementation
proc DebugList(const List: L; const Msg: String);
begin
Pipe(List).Debug(Msg); // Convert TList<V> to TCollPipe once
end;
_
Pipe(List).Debug(Msg); // Convert TList<V> to TCollPipe once
__;
Fn SortAndDebug(const List: L; Compare: TCompareFunc; const Msg: String): L;
_
Result := Pipe(List)
.Sort(Compare)
.Debug(Msg)
.ToArray;
__;
_
Result := Pipe(List)
.Sort(Compare)
.Debug(Msg)
.ToArray;
__;
Fn TCollPipe.Count: Integer;
_
Result := FData.Count;
__;
_
Result := FData.Count;
__;
Fn TCollPipe.GroupBy(KeyFunc: TMapperFunc): spec TDictionary<V, L>;
var
i: Integer;
key: V;
group: L;
_
Result := spec TDictionary<V, L>.Create;
for i := 0 to FData.Count - 1 do
var
i: Integer;
key: V;
group: L;
_
key := KeyFunc(FData[i], i);
if not Result.TryGetValue(key, group) then
Result := spec TDictionary<V, L>.Create;
for i := 0 to FData.Count - 1 do
_
group := L.Create;
Result.Add(key, group);
key := KeyFunc(FData[i], i);
if not Result.TryGetValue(key, group) then
_
group := L.Create;
Result.Add(key, group);
__;
group.Add(FData[i]);
__;
group.Add(FData[i]);
__;
__;
Fn TCollPipe.ForAll(Predicate: TPredicateFunc): Boolean;
var
i: Integer;
_
Result := True;
for i := 0 to FData.Count - 1 do
var
i: Integer;
_
if not Predicate(FData[i], i) then
Result := True;
for i := 0 to FData.Count - 1 do
_
Result := False;
Exit;
if not Predicate(FData[i], i) then
_
Result := False;
Exit;
__;
__;
__;
__;
Fn List( const Elements: array of V ): L ;
@ -212,14 +214,15 @@ implementation
Fn TCollPipe.Sort( Compare: TCompareFunc ): TCollPipe;
var
NewList: L;
_
NewList := L.Create;
NewList.AddRange(FData);
NewList.Sort(spec TComparer<V>.Construct(Compare));
Result := TCollPipe.Create(NewList);
__ ;
var
NewList: L;
_
NewList := L.Create;
NewList.AddRange(FData);
NewList.Sort(spec TComparer<V>.Construct(Compare));
Result := TCollPipe.Create(NewList);
__ ;
@ -290,8 +293,7 @@ implementation
Result := Func( Result, Arr[ i ], i ) ;
__ ;
end. ( * ) unit MRF3 ( * )
end. (*) unit MRF3 (*)
======================================================================
program testMRF3;

View file

@ -1,6 +0,0 @@
function f ($y) {
$y*$y
}
function g (${function:f}, $y) {
(f $y)
}

View file

@ -1,6 +0,0 @@
function g2($y) {
function f2($y) {
$y*$y
}
(f2 $y)
}

View file

@ -1,30 +0,0 @@
REBOL [
Title: "Function Argument"
URL: http://rosettacode.org/wiki/Function_as_an_Argument
]
map: func [
"Apply function to contents of list, return new list."
f [function!] "Function to apply to list."
data [block! list!] "List to transform."
/local result i
][
result: copy [] repeat i data [append result f i] result]
square: func [
"Calculate x^2."
x [number!]
][x * x]
cube: func [
"Calculate x^3."
x [number!]
][x * x * x]
; Testing:
x: [1 2 3 4 5]
print ["Data: " mold x]
print ["Squared:" mold map :square x]
print ["Cubed: " mold map :cube x]
print ["Unnamed:" mold map func [i][i * 2 + 1] x]

View file

@ -1,6 +1,7 @@
include Settings
-- 23 Aug 2025
include Setting
say 'HIGHER-ORDER FUNCTIONS - 2 Mar 2025'
say 'HIGHER-ORDER FUNCTIONS'
say version
say
call Calculate '1/x',6
@ -13,11 +14,9 @@ call Calculate 'x**2-3*x+Arcsin(x)-Sinh(x)/x-Pi()+E()',1/3
exit
Calculate:
procedure
procedure expose Memo.
parse arg ff,xx
say ff 'for x='xx 'makes' Eval(ff,xx)+0
return
include Functions
include Constants
include Abend
include Math