On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote:
I am writing a domain specific language of sorts in D for the
lambda calculus. One of my requirements is that I should be
able to generate expressions like this:
new Abstraction(v1, M)
like this:
L!(x => M)
A word of caution: this
On Monday, 25 February 2019 at 08:24:06 UTC, Yevano wrote:
One thing. The variables were reversed. Fixed by changing these
lines.
auto result = new Abstraction(vars[$ - 1], f(vars));
foreach_reverse(e; vars[0..$ - 1]) {
result = new Abstraction(e, result);
}
Yup. I assumed that didn't ma
One thing. The variables were reversed. Fixed by changing these
lines.
auto result = new Abstraction(vars[$ - 1], f(vars));
foreach_reverse(e; vars[0..$ - 1]) {
result = new Abstraction(e, result);
}
On Monday, 25 February 2019 at 07:40:51 UTC, Simen Kjærås wrote:
The simple scalable version - just change maxArgs to a number
that suits you:
It works! Thanks. Didn't know about static foreach.
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote:
This only works for at most 3 parameter delegates. If I want to
add more, I have to linearly add more static ifs in the obvious
way. However, I believe I can make this function scalable using
string mixins and other magic. Any insight i
On Monday, 25 February 2019 at 07:03:21 UTC, Nicholas Wilson
wrote:
import std.traits;
Abstraction L(alias f)() {
alias Args = Parameters!f;
Args v;
foreach(i; 0 .. v.length) v[i] = new Variable;
auto _f = f(v);
auto abstraction = new Abstraction(v[$-1],_f);
foreach
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote:
I am writing a domain specific language of sorts in D for the
lambda calculus. One of my requirements is that I should be
able to generate expressions like this:
new Abstraction(v1, M)
like this:
L!(x => M)
It is common to want to w