Skip to content

Instantly share code, notes, and snippets.

@hodzanassredin
Created May 10, 2023 09:44
Show Gist options
  • Save hodzanassredin/600b3f0cf33a2e0bb60a69368da42b64 to your computer and use it in GitHub Desktop.
Save hodzanassredin/600b3f0cf33a2e0bb60a69368da42b64 to your computer and use it in GitHub Desktop.
component pascal currying example
TYPE Vector* = POINTER TO ARRAY OF REAL;
Mapper2 = PROCEDURE (x,y:Vector) : Vector;
Mapper = POINTER TO ABSTRACT RECORD END;
Closure = POINTER TO RECORD (Mapper)
f : Mapper2;
x : Vector;
END;
PROCEDURE (m:Mapper) Apply(v : Vector) : Vector , NEW, ABSTRACT;
PROCEDURE (c:Closure) Apply(v : Vector) : Vector;
BEGIN
RETURN c.f(c.x, v);
END Apply;
PROCEDURE Curry*(m : Mapper2; x: Vector):Mapper;
VAR c : Closure;
BEGIN
c.f := m;
c.x := x;
RETURN c;
END Curry;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment