Re: Tristate - wanna?

2016-03-31 Thread Nordlöw via Digitalmars-d
On Saturday, 26 March 2016 at 22:11:53 UTC, Nordlöw wrote: Partial implementation at https://github.com/nordlow/justd/blob/master/fuzzy.d#L15 moved to https://github.com/nordlow/justd/blob/master/nstate.d#L15

Re: Tristate - wanna?

2016-03-27 Thread sarn via Digitalmars-d
On Saturday, 26 March 2016 at 22:39:58 UTC, Alex Parrill wrote: On Saturday, 26 March 2016 at 22:11:53 UTC, Nordlöw wrote: I can think of many variants of for this. What about { yes, // 1 chance no, // 0 chance likely, // > 1/2 chance unlikely, // < 1/2 chance

Re: Tristate - wanna?

2016-03-27 Thread crimaniak via Digitalmars-d
On Sunday, 27 March 2016 at 02:36:47 UTC, Alex Parrill wrote: ... a && b == min(a, b) a || b == max(a, b) ~a == N-1-a why to optimize it more? That's incorrect for the `unknown` value. Lets say you represented true as 1f, false as 0f, and unknown as NaN... std.algorithm.max(0, 0f/0f) = 0,

Re: Tristate - wanna?

2016-03-27 Thread Johan Engelen via Digitalmars-d
On Saturday, 26 October 2013 at 21:05:36 UTC, Andrei Alexandrescu wrote: One challenge in Tristate (or the as-of-yet-unwritten Fourstate) is to define the primitives |, &, ^, and ~ with minimum of operations. For example Tristate still has conditionals in two of them, which I think could be

Re: Tristate - wanna?

2016-03-26 Thread Andrei Alexandrescu via Digitalmars-d
On 03/26/2016 10:36 PM, Alex Parrill wrote: N-state logic isn't just about probabilities either. According to Wikipedia, Bochvar's three-valued logic has an "internal" state, where any operation with `internal` results in `internal` (similar to NaN). More broadly, the values and operations

Re: Tristate - wanna?

2016-03-26 Thread Alex Parrill via Digitalmars-d
On Sunday, 27 March 2016 at 02:19:56 UTC, crimaniak wrote: On Saturday, 26 March 2016 at 22:39:58 UTC, Alex Parrill wrote: ... If we're going down that route, might as well use state tables. ... For Boolean, Ternary, and N-state logic: a && b == min(a, b) a || b == max(a, b) ~a == N-1-a

Re: Tristate - wanna?

2016-03-26 Thread crimaniak via Digitalmars-d
On Saturday, 26 March 2016 at 22:39:58 UTC, Alex Parrill wrote: ... If we're going down that route, might as well use state tables. ... For Boolean, Ternary, and N-state logic: a && b == min(a, b) a || b == max(a, b) ~a == N-1-a why to optimize it more?

Re: Tristate - wanna?

2016-03-26 Thread Alex Parrill via Digitalmars-d
On Saturday, 26 March 2016 at 22:11:53 UTC, Nordlöw wrote: On Saturday, 26 October 2013 at 15:41:32 UTC, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it

Re: Tristate - wanna?

2016-03-26 Thread Nordlöw via Digitalmars-d
On Saturday, 26 October 2013 at 15:41:32 UTC, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? I can think of many variants of for this. What

Re: Tristate - wanna?

2013-10-31 Thread Lionello Lunesu
On 10/26/13, 17:42, Andrei Alexandrescu wrote: unittest { Tristate a; assert(a == Tristate.no); Why not have '0' map to unknown? Seems to more useful, like float.nan and the like. L.

Re: Tristate - wanna?

2013-10-31 Thread Andrei Alexandrescu
On 10/31/13 2:35 AM, Lionello Lunesu wrote: On 10/26/13, 17:42, Andrei Alexandrescu wrote: unittest { Tristate a; assert(a == Tristate.no); Why not have '0' map to unknown? Seems to more useful, like float.nan and the like. So logical operations are closer to the built-in Boolean

Re: Tristate - wanna?

2013-10-30 Thread Lionello Lunesu
On 10/27/13, 11:07, Timon Gehr wrote: On 10/27/2013 02:11 AM, Andrei Alexandrescu wrote: On 10/26/13 5:13 PM, Timon Gehr wrote: The following implementation does not use conditionals; probably not minimal. Thanks! Fixed two minor bugs: this(bool b) { value = b; } void opAssign(bool b) {

Re: Tristate - wanna?

2013-10-30 Thread Timon Gehr
On 10/30/2013 04:43 PM, Lionello Lunesu wrote: On 10/27/13, 11:07, Timon Gehr wrote: On 10/27/2013 02:11 AM, Andrei Alexandrescu wrote: On 10/26/13 5:13 PM, Timon Gehr wrote: The following implementation does not use conditionals; probably not minimal. ... Couldn't this be optimized

Re: Tristate - wanna?

2013-10-28 Thread Denis Shelomovskij
27.10.2013 4:08, Timon Gehr пишет: On 10/26/2013 05:42 PM, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? Theory:

Re: Tristate - wanna?

2013-10-27 Thread Timon Gehr
On 10/27/2013 02:11 AM, Andrei Alexandrescu wrote: On 10/26/13 5:13 PM, Timon Gehr wrote: The following implementation does not use conditionals; probably not minimal. Thanks! Fixed two minor bugs: this(bool b) { value = b; } void opAssign(bool b) { value = b; } These should

Tristate - wanna?

2013-10-26 Thread Andrei Alexandrescu
While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? Theory: http://en.wikipedia.org/wiki/Three-state_logic struct Tristate { private ubyte value; private static

Re: Tristate - wanna?

2013-10-26 Thread Walter Bright
On 10/26/2013 8:42 AM, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? Theory: http://en.wikipedia.org/wiki/Three-state_logic When I worked

Re: Tristate - wanna?

2013-10-26 Thread Andrei Alexandrescu
On 10/26/13 12:17 PM, Walter Bright wrote: On 10/26/2013 8:42 AM, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? Theory:

Re: Tristate - wanna?

2013-10-26 Thread Timon Gehr
On 10/26/2013 05:42 PM, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial. Should we add it to stdlib? Theory: http://en.wikipedia.org/wiki/Three-state_logic The term

Re: Tristate - wanna?

2013-10-26 Thread Timon Gehr
On 10/26/2013 11:06 PM, Andrei Alexandrescu wrote: On 10/26/13 12:17 PM, Walter Bright wrote: On 10/26/2013 8:42 AM, Andrei Alexandrescu wrote: While messing with std.allocator I explored the type below. I ended up not using it, but was surprised that implementing it was quite nontrivial.

Re: Tristate - wanna?

2013-10-26 Thread Andrei Alexandrescu
On 10/26/13 5:13 PM, Timon Gehr wrote: The following implementation does not use conditionals; probably not minimal. Thanks! Fixed two minor bugs: this(bool b) { value = b; } void opAssign(bool b) { value = b; } These should shift b so it becomes 2 if true. Pushed your code