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,13 +0,0 @@
generic
type Argument is private;
package Functions is
type Primitive_Operation is not null
access function (Value : Argument) return Argument;
type Func (<>) is private;
function "*" (Left : Func; Right : Argument) return Argument;
function "*" (Left : Func; Right : Primitive_Operation) return Func;
function "*" (Left, Right : Primitive_Operation) return Func;
function "*" (Left, Right : Func) return Func;
private
type Func is array (Positive range <>) of Primitive_Operation;
end Functions;

View file

@ -1,25 +0,0 @@
package body Functions is
function "*" (Left : Func; Right : Argument) return Argument is
Result : Argument := Right;
begin
for I in reverse Left'Range loop
Result := Left (I) (Result);
end loop;
return Result;
end "*";
function "*" (Left, Right : Func) return Func is
begin
return Left & Right;
end "*";
function "*" (Left : Func; Right : Primitive_Operation) return Func is
begin
return Left & (1 => Right);
end "*";
function "*" (Left, Right : Primitive_Operation) return Func is
begin
return (Left, Right);
end "*";
end Functions;

View file

@ -1,12 +0,0 @@
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
with Ada.Text_IO; use Ada.Text_IO;
with Functions;
procedure Test_Compose is
package Float_Functions is new Functions (Float);
use Float_Functions;
Sin_Arcsin : Func := Sin'Access * Arcsin'Access;
begin
Put_Line (Float'Image (Sin_Arcsin * 0.5));
end Test_Compose;

View file

@ -6,9 +6,9 @@ extension op : Func1
= (x => self(f(x)));
}
public program()
public Program()
{
var fg := (x => x + 1).compose::(x => x * x);
console.printLine(fg(3))
Console.printLine(fg(3))
}

View file

@ -1,7 +0,0 @@
;; lexical-binding: t
(defun compose (f g)
(lambda (x)
(funcall f (funcall g x))))
(let ((func (compose '1+ '1+)))
(funcall func 5)) ;=> 7

View file

@ -1,5 +0,0 @@
(defun compose (f g)
`(lambda (x) (,f (,g x))))
(let ((func (compose '1+ '1+)))
(funcall func 5)) ;=> 7

View file

@ -1,5 +0,0 @@
(defmacro compose (f g)
`(lambda (x) (,f (,g x))))
(let ((func (compose 1+ 1+)))
(funcall func 5)) ;=> 7

View file

@ -1,7 +0,0 @@
function g ($x) {
$x + $x
}
function f ($x) {
$x*$x*$x
}
f (g 1)

View file

@ -1,4 +0,0 @@
function fg (${function:f}, ${function:g}, $x) {
f (g $x)
}
fg f g 1

View file

@ -1,14 +0,0 @@
REBOL [
Title: "Functional Composition"
URL: http://rosettacode.org/wiki/Functional_Composition
]
; "compose" means something else in REBOL, therefore I use a 'compose-functions name.
compose-functions: func [
{compose the given functions F and G}
f [any-function!]
g [any-function!]
] [
func [x] compose [(:f) (:g) x]
]

View file

@ -1,8 +0,0 @@
foo: func [x] [reform ["foo:" x]]
bar: func [x] [reform ["bar:" x]]
foo-bar: compose-functions :foo :bar
print ["Composition of foo and bar:" mold foo-bar "test"]
sin-asin: compose-functions :sine :arcsine
print [crlf "Composition of sine and arcsine:" sin-asin 0.5]

View file

@ -1,3 +1,21 @@
compose: procedure; parse arg f,g,x; interpret 'return' f"(" g'(' x "))"
-- 12 Sep 2025
include Setting
exit /*control should never gets here, but this was added just in case.*/
say 'FUNCTION COMPOSITION'
say version
say
parse value 'Sin' 'ArcSin' 0.5 with ff gg xx
say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' Sin(ArcSin(xx))
parse value 'ArcSin' 'Sin' 0.5 with ff gg xx
say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' ArcSin(Sin(xx))
parse value 'Zeta' 'Gamma' 0.5 with ff gg xx
say 'Compose('ff','gg','xx')' '=' Compose(ff,gg,xx) ',' ff'('gg'('xx'))' '=' Zeta(Gamma(xx))
exit
Compose:
procedure expose Memo.
arg ff,gg,xx
interpret 'rr='ff'('gg'('xx'))'
return rr
include Math

View file

@ -1,18 +0,0 @@
option explicit
class closure
private composition
sub compose( f1, f2 )
composition = f2 & "(" & f1 & "(p1))"
end sub
public default function apply( p1 )
apply = eval( composition )
end function
public property get formula
formula = composition
end property
end class

View file

@ -1,26 +0,0 @@
dim c
set c = new closure
c.compose "ucase", "lcase"
wscript.echo c.formula
wscript.echo c("dog")
c.compose "log", "exp"
wscript.echo c.formula
wscript.echo c(12.3)
function inc( n )
inc = n + 1
end function
c.compose "inc", "inc"
wscript.echo c.formula
wscript.echo c(12.3)
function twice( n )
twice = n * 2
end function
c.compose "twice", "inc"
wscript.echo c.formula
wscript.echo c(12.3)