you are welcome to use
implies(p::Bool, q::Bool) = !p | q    
{ !p, ~p likely compile to the same instructions -- they do for me; you 
might prefer to use of !p here as that means 'logical_not(p)' where ~p 
means 'flip_the_bits_of(p)' }

I find that this form is also 40% slower than the ifelse form.



On Thursday, October 6, 2016 at 4:11:55 PM UTC-4, Kevin Liu wrote:
>
> Is this why I couldn't find implication in Julia? 
>
> Maybe it was considered redundant because (1) it is less primitive than 
>> "^", "v", "~", (2) it saves very little typing since "A => B" is equivalent 
>> to "~A v B". – Giorgio 
>> <http://programmers.stackexchange.com/users/29020/giorgio> Jan 18 '13 at 
>> 14:50 
>> <http://programmers.stackexchange.com/questions/184089/why-dont-languages-include-implication-as-a-logical-operator#comment353607_184089>
>
>
> Wikipedia also says the implication table is identical to that of ~p | q. 
> So instead just the below?
>
> julia> ~p | q 
>
> false
>
>
> I'll take that.
>
> On Thursday, October 6, 2016 at 4:08:00 PM UTC-3, Jeffrey Sarnoff wrote:
>>
>> (the version using ifelse benchmarks faster on my system)
>>
>> On Thursday, October 6, 2016 at 3:05:50 PM UTC-4, Jeffrey Sarnoff wrote:
>>>
>>> here are two ways
>>>
>>> implies(p::Bool, q::Bool) = !(p & !q)
>>>
>>> implies(p::Bool, q::Bool) = ifelse(p, q, true)
>>>
>>>
>>>
>>>
>>> On Thursday, October 6, 2016 at 12:10:51 PM UTC-4, Kevin Liu wrote:
>>>>
>>>> How is an implication represented in Julia? 
>>>>
>>>>
>>>> https://en.wikipedia.org/wiki/Material_conditional#Definitions_of_the_material_conditional
>>>>
>>>

Reply via email to