Rant after trying Rust a bit
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 13 14:33:39 PDT 2016
On Monday, 11 July 2016 at 17:02:50 UTC, Max Samukha wrote:
> BTW, it happens that '+' does not always have to be
> commutative: https://en.wikipedia.org/wiki/Near-ring
> https://en.wikipedia.org/wiki/Ordinal_arithmetic#Addition
Yes, although concatenations ought to be «*»... and the empty
string «""» the identity (1).
e.g. a free monoid:
"abc" * "d" == "abcd"
"abc"*"" == "abc"
"abc"*""*"" == "abc"
Then if you want to represent a set of alternate sets like a
regexp «ab|cd» you could replace the alternative operator «|»
with «+» and let the empty set «{}» be zero (0). Thus get a
semiring:
( {"a"} + {"b"} ) + {"c"} == {"a"} + ( {"b"} + {"c"} ) == {"a" +
"b" + "c"}
{} + {"a"} == {"a"} + {} == {"a"}
{"a"} + {"b"} == {"b"} + {"a"} == {"a" + "b"}
( {"a"} * {"b"} ) * {"c"} == {"a"} * ( {"b"} * {"c"} ) == {"abc"}
{"a"} * ({"b"} + {"c"}) == ({"a"} * {"b"}) + ({"a"} * {"c"}) == {
"ab" + "ac" }
({"a"} + {"b"}) * {"c"} == ({"a"} * {"c"}) + ({"b"} * {"c"}) ==
{"ab + "bc" }
{""} * {"a"} == {"a"} * {""} == {"a"}
{} * {"a"} == {"a"} * {} == {}
Sortof...
More information about the Digitalmars-d
mailing list