Created
May 10, 2023 09:44
-
-
Save hodzanassredin/600b3f0cf33a2e0bb60a69368da42b64 to your computer and use it in GitHub Desktop.
component pascal currying example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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