Check out Modern Chess, our featured variant for January, 2025.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier History. History of the Chess Variants Game Courier PBM system.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Thu, Dec 3, 2015 01:05 AM UTC:

I am extending GAME Code to better support Lambda functions. This is an anonymous, unnamed function. I have created a new variable type for storing functions. Although a function is simply stored as an array, I wanted to know when an array is supposed to be a function. So I created a PHP class called Lambda, which holds an array that represents a function.

I created the lambda operator for expressions. This will convert an array, a string, or the function associated with a function name to a Lambda object. This can be used with the fn operator to run a Lambda object as a function.

One immediate consequence of this is that you can store functions in variables, and you can call a function with a variable instead of a function name. For example:

set a lambda (* #0 #1);
set b fn #a 6 8;

The second line multiplies 6 by 8 and sets b to 48.

I am also working on expanding some built-in functions to make lambda functions more useful. Here's an example of an expression using a lambda function to find the location of the Black King:

set k anytrue lambda (#0 onlyif == space #0 k) spaces;

The anytrue function, if given a lambda function as its first argument, goes through all the values of an array given as a second argument, calling the function for each value in the array until it finds a true value. The value from the array goes into #0. If the array element is an array itself, the function may have more than one argument. For example:

set k anytrue lambda (#0 onlyif == space #0 #1) ((e1 k) (e8 k) (g1 N));

Because a string can be converted to a lambda function, it is now possible for the program to write a function and call it. More on this later