{"body":"class Logic::Ternary does Enumeration {\n\tmy %enumerations =\n\t\tFalse   => -1,\n\t\tUnknown =>  0,\n\t\tTrue    => +1,\n\t;\n\tmy %anti = %enumerations.antipairs;\n\n\tmethod new(Str:D $val where <False Unknown True>.one) {\n\t\tself.bless: key => $val, value => %enumerations{$val}\n\t}\n\n\tmethod ^enum_from_value($, $value) {\n\t\tmy $key = do given $value {\n\t\t\twhen $_ =:= True    {             +1 }\n\t\t\twhen $_ =:= False   {             -1 }\n\t\t\twhen !*.defined     {              0 }\n\t\t\twhen $_ !~~ Numeric { .so ?? 1 !! -1 }\n\t\t\twhen 0              {              0 }\n\t\t\twhen Numeric        {    $_ div .abs }\n\t\t\tdefault             { .so ?? 1 !! -1 }\n\t\t}\n\t\t::?CLASS.new: %anti{$key}\n\t}\n\n\tmethod is-true    { self >  0 }\n\tmethod is-false   { self <  0 }\n\tmethod is-unknown { self == 0 }\n\n\tmulti method ACCEPTS( ::?CLASS:D: ::?CLASS:D $other ) { self == $other }\n\n\tmethod not(--> ::?CLASS) { (-1 * self).Ternary }\n\n\tmethod so { self }\n\n\tmethod Bool {\n\t\treturn Bool without self;\n\t\t$.is-true\n\t}\n\n\tproto method COERCE($)                    {            * }\n\tmulti method COERCE(Bool:D $ where *.so ) { ::?CLASS(+1) }\n\tmulti method COERCE(Bool:D $ where *.not) { ::?CLASS(-1) }\n\tmulti method COERCE(Bool:U)               { ::?CLASS( 0) }\n}\n","name":"","extension":"raku","url":"https://www.irccloud.com/pastebin/fb9aqpiE","modified":1761073972,"id":"fb9aqpiE","size":1215,"lines":45,"own_paste":false,"theme":"","date":1761073972}