Somewhat OT: defining algebras in D

Simen Kjærås simen.kjaras at gmail.com
Fri Feb 9 17:10:11 UTC 2018


On Friday, 9 February 2018 at 15:45:11 UTC, Amorphorious wrote:
> On Friday, 9 February 2018 at 02:40:06 UTC, Nick Sabalausky 
> (Abscissa) wrote:
>> Well, that's the difference between a formal library package 
>> release vs sharing a working proof of concept jotted down to 
>> pass time ;)
>
> Yes, but he can go back an add some friendly text at some 
> point... He knows most about it so it is much easier and 
> shouldn't take more than a few mins.

Indeed I can, and I have:

https://gist.github.com/Biotronic/833680b37d4afe774c8562fd21554c6b

Doing so after a long, tiring day at work for something I just 
did to pass the time, though - not worth it when I wanted a 
shower and some sleep. Luckily, today was just as boring, so I 
cleaned up the syntax a bit, added more sensible error messages, 
and even made it do the right thing by default when you leave out 
a rule:

alias complex = Algebra!(
         float,
         "1,i",
         "i" * "i".op = -1);
alias dual = Algebra!(
         float,
         "1,e",
         "e" * "e".op = 0);
alias splitComplex = Algebra!(
         float,
         "1,j",
         "j" * "j".op = 1
         );
alias quaternion = Algebra!(
         float,
         "1,i,j,k",
         "i,j,k" * "i,j,k".op = -1,
         "i,j,k" * "j,k,i".op = "k,i,j".antiCommutative
         );

--
   Simen


More information about the Digitalmars-d mailing list