Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMP - Not this old chestnut again
#1
I've been having so/so results using the IMP logical operator, mostly falling back on all the other operators or Select Case. Recently, because we now have Co-Pilot and Gemini I have revisited my IMP failures. Gemini is now telling me that QB64PE either has  a bug or mishandles string values with the IMP logical operator. It starts back with the following simple code:

Code: (Select All)
Input "Which color do you prefer? Pink or Blue: ",C$

If C$ = "Pink" IMP "Girl" then
Print "You're a Girl!"
Elseif C$ = "Blue" IMP "Boy" then
Print "You"re a Boy!"
Else
Print " Invalid color choice"
End If
 
Gemini feels this code is correct and should generate the correct response however the IDE highlights an error on the ' If C$ = "Pink" IMP "Girl" then' line. The error message reads that I cannot convert a number to a string. It seems the left side of the IMP operator is fine ( ie If C$ = "Pink" but the right side of IMP is looking for a number and does not recognize a string value.

Tried changing the right side to a Boolean comparison ( ie If C$ = "Pink" IMP NOT("Girl" = "") but still can't come up with the correct answer. Trying to get Gemini to keep correcting the code to make IMP work with this set of conditions it became frustrated with me (of course that's how I took it and not real frustration on its part) and gave a very simple Select Case routine to deal with this simple color question.

While Gemini was thinking the above was an issue for IMP dealing with string values it told me QB64PE could have a bug in its application of IMP after the following code using IMP was tested :

Code: (Select All)
Input "Enter your age: ", age
isADULT = age >= 18

If isADULT Imp True Then
    Print "You are an Adult"
Else
    Print "You are a minor"
End If
 
The above code was Gemini's answer to a previous attempt on the use of IMP and touts that this code gives the correct answer. Gemini's actual defense of this code reads  " The issue was that the isADULT variable was being assigned the result of the comparison age >= 18. This means that isADULT would be True only if the age is greater than or equal to 18. However, the IMP operator was being used incorrectly. The IMP operator should be used to check if the condition "age is greater than or equal to 18 implies adult" is True.

But Gemini's "corrected code" still does NOT give the correct answer.

Moral of the story : To And, Or or XOR is devine to IMP is just gossip.
Reply
#2
This accomplishes the first code directly:
Code: (Select All)
Input "Which color do you prefer? Pink or Blue: ", C$
If C$ = "Pink" Then
    Print "You're a Girl!"
ElseIf C$ = "Blue" Then
    Print "You're a Boy!" ' Dimster had typo You"re
Else
    Print " Invalid color choice"
End If

Why mess with something simple and straight forward?

The thing about IMP as bit operator (not particularly Logical in human sense) which does need numbers to operate on is that when the premise A is false IMP will return True, does not matter what 2nd premise B is true or false.
This completes the Truth Table for doing bit operations and the sole reason why IMP exists, so you can have a special set of results for each combination TF premise A and TF premise B. If A is false it returns True regardless what B is.
b = b + ...
Reply
#3
A IMP B

(NOT A) OR B

The two statements above are basically perfect replacements for each other.  So what you're saying with "Pink" IMP "Girl" is basically:

IF (NOT "Pink") OR "Girl" THEN

Now, since those are bitwise comparisons, can you see why that doesn't work at all?
Reply
#4
I totally agree. There are oh so many ways to code to avoid anything to do with IMP. 

However, my fascination with it is that it appears to be the only Logical Operator that is not logical at all. A computer only understands 1 and 0 so all your coding not only needs to have a logical flow but comes down to just 2 things - 1 or 0. The case of IMP has more of a hint of human logic than computer logic. We humans IMPLY tons of things, like Captain Kirk v's Spock. I'm not sure if our society still finds it appropriate to imply Blue is for Boys but when we look at some one in blue at the very far end of the Mall hallway, we could be thinking "that guy up there.." 

In terms of AI generative making it to the next level of AI general, I'm thinking IMP may take on new importance role in prediction.
Reply
#5
IMP is just shorthand for NOT A OR B.

a IMP b....   NOT a OR b

That's all it is.  All it does.   Nothing fancy to see here.  Just 2 letters less typing.  The compiler probably translates both into the exact same assembly, in the end.
Reply
#6
Interesting thing. But IMP is not completely useless.
Example of how logical operators can be used to decide on the creditworthiness of a loan applicant.

Code: (Select All)

'Beispiel fuer logischen Operator IMP; S. 88 - 16. Okt. 2024
'Die Antwort hat keine Auswirkung, nur Kredithoehe zu Monatsverdienst.

'The answer has no effect, only the loan amount is related to monthly income.  A mistake?

Screen _NewImage(800, 400, 32)
Option _Explicit

Dim As Double kreditHoehe, monatsVerdienst
Dim As String antwort

Locate 3, 3
Print "Kreditantrag" 'Loan application
Locate 4, 3
Print "============"

Locate 6, 3
Input "Hoehe des gewuenschten Kredits                  : ", kreditHoehe 'Amount Of desired loan
Locate 7, 3
Input "Arbeitet der Antragsteller in Vollzeit(Ja/Nein)?: ", antwort 'Is the applicant working full-time?
Locate 8, 3
Input "Wie hoch ist der Monatsverdienst?              : ", monatsVerdienst 'Monthly earnings

'Since the applicant is employed full-time, the loan application is approved in the amount of
If kreditHoehe > monatsVerdienst Imp UCase$(antwort) = "Ja" Then
  Locate 10, 3
  Print "Da der Antragsteller einer Vollzeitbeschaeftigung nachgeht,"
  Locate 11, 3
  Print Using "wird der Kreditantrag in Hoehe von ###,###.## Euro genehmigt."; kreditHoehe
  'The applicant does not meet the conditions for a loan of ... The application is denied.
Else
  Beep
  Locate 10, 3
  Print Using "Der Antragsteller erfuellt die Bedingungen fuer einen Kredit in Hoehe von ###,###.## nicht."; kreditHoehe
  Locate 11, 3
  Print "Der Antrag wird abgelehnt."
End If

End

PS: For better understanding

[Image: IMP-Wahrheitstabelle.jpg]
Reply
#7
Code: (Select All)

a = Boy
b = Girl ' That's right fumeinist, deal with it.
Transgender = a Imp b

Pete

 - The Bud Light's on but nobody's buying it.
Reply
#8
(10-16-2024, 10:25 PM)Pete Wrote:
Code: (Select All)

a = Boy
b = Girl ' That's right fumeinist, deal with it.
Transgender = a Imp b

Pete

 - The Bud Light's on but nobody's buying it.
What Sacrilege Pete.  How dare you define what a girl is.  What gall you have for doing it.  There are millions of people (the unwashed part) when ask "What is a girl ?"  Won't or can't do it.

/sarcasm off
Reply
#9
My granny -- born in 1880 and who only had a third grade education -- could even tell you rhe definition for a boy/girl.   According to granny:

"A boy has three knees.  A right knee.  A left knee.  And a WEENY!   A girl don't."

Swore by that so much so, that even after WWII, when my uncle (her brother) came home with a leg missing, she told him, "Guess you gots to start wearing a dress now, seeing as how you ain't a REAL man, no more!"
Reply
#10
Dear Dimster

why do you like waste your time with Gemini IA and with IMP logic operator?

if you run in QB64IDE your second code example you'll get the wrong result until you would type () around age>=18 and you set True = -1.


try to run this code in QB64IDE
Code: (Select All)

age = 5
Print isADULT = age >= 18, age, isADULT Imp True, True
age = 25
Print isADULT = age >= 18, age, isADULT Imp True, True

here to learn IMP logic operator how it works...
IMP logic operator (english)

but Gemini IA is a great donkey if it wants to get IMP logic result passing to IMP a not boolean arguments.
synthax  Boolean1 IMP Boolean2
as KernelPanic has showed into his code

Code: (Select All)

If kreditHoehe > monatsVerdienst Imp UCase$(antwort) = "Ja" Then

Quote:Moral of the story : To And, Or or XOR is devine to IMP is just gossip
yeah and this is another GOSSIP
GOSSIP (Maneskin)

Take care of your time friend!
Reply




Users browsing this thread: 2 Guest(s)