Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMP - Not this old chestnut again
#14
(10-22-2024, 04:51 PM)Dimster Wrote: I appreciate the IMP code, I have added it to my collection of IMP sample codes. By the way, do you recall this one?

Code: (Select All)
'IMP demo in multiple cases
Randomize Timer
_Title "IMProbable Demonstrations of the IMPossible Logic Operator named IMP..."
'demo  OutOfRange  InTheRange Lowest Uppest
Do
    n$ = UCase$(InKey$)
    If n$ = Chr$(27) Then End
    If n$ <> "" And InStr("OILU", n$) Then
        Cls
        For a = 1 To 10
            b = Int(Rnd * 40) + 1
            c = Int(Rnd * 30) + 2 + b
            d = Int(Rnd * 79) + 1
            Locate (a - 1) * 2 + 1, 1
            Print b; "  "; c; "  "; d; "  ";
            If n$ = "O" Then If outheRange(b, c, d) Then Print "out of range "; ' Else Print "in the range ";
            If n$ = "I" Then If intheRange(b, c, d) = -1 Then Print "In the range<---";
            If n$ = "L" Then If Lowest(b, c, d) Then Print "lowest  is "; d
            If n$ = "U" Then If Uppest(b, c, d) Then Print "Uppest  is "; d
            ' graphic rappresentation
            Color 2, 0: Locate (a - 1) * 2 + 2, b: Print ">";: Locate , c: Print "<";: Color 14, 0: Locate , d: Print "O";: Color 7, 0
        Next a
    End If
    Locate 23, 1: Print " Outherange Intherange Lowest Uppest, Escape to quit"
    Color 14, 0: Locate 23, 2: Print "O";: Locate 23, 13: Print "I";: Locate 23, 24: Print "L";: Locate 23, 31: Print "U";: Color 7, 0
    _Limit 10
Loop


' SUB and FUNCTION area  / area delle SUB e delle FUNCTION
Function outheRange (min As Integer, max As Integer, value As Integer)
    outheRange = 0
    outheRange = (min <= value Imp value >= max)
End Function

Function intheRange (min As Integer, max As Integer, value As Integer)
    intheRange = 0
    intheRange = (value <= max) Imp (value <= min)
    intheRange = Not intheRange
End Function

Function Lowest (a1%, a2%, T%)
    'NOT a OR b
    '3 8 1 -> F imp F = T
    '3 8 4 -> T imp F = F  no lowest
    '5 3 2 -> F imp T = T
    '6 4 9 -> T imp T = T  --> bug that it solves ordering a1% vs a2%
    If a1% > a2% Then Swap a1%, a2%
    Lowest = a1% < T% Imp a1% > a2%
End Function

Function Uppest (a1%, a2%, T%)
    'NOT a OR b
    '3 8 9 -> F imp T = T
    '3 2 6 -> F imp F = T
    '5 6 2 -> T imp T = T  -->bug  that it solves ordering a1% vs a2%
    '6 4 2 -> T imp F = F no uppest
    If a1% < a2% Then Swap a1%, a2%
    Uppest = a1% > T% Imp a1% < a2%
End Function
I get an error on the "Function intheRange" but love the Title of the program.

In terms of using AI, I'm afraid that train has left the station, we are going to be inundated with it.
Interesting you have mentioned Popper, it is his falsification theory that I find my computer understands the most ( ie A theory is Valid Until Proven False). Trouble is my computer is suggesting more of my theories are proven false than true. New Theory, I think my computer has a drinking problem.
Hey Boy
do you bring me a code that is familiar to me!  Smile

You get error after pasting this code into QB64peIDE because it had been written when there was an issue about Function parsing.
After correction of that issue the line of code
Code: (Select All)

InTheRange = NOT InTheRange
activates an error warning of calling InTheRange without parameters.
So to use NOT on the result of IMP operator we must use a TeMPorary variable tmp and then assign to the function InTheRange the correct result.

here code:
Code: (Select All)

Function intheRange (min As Integer, max As Integer, value As Integer)
    intheRange = 0
    tmp = (value <= max) Imp (value <= min)
    intheRange = Not tmp
    '  intheRange = Not intheRange        REM <----------- this instruction is an error now that compiler solved the issue about functions
End Function

So do you like my little IMProbable IMP library? Thanks

Dear Dimster about Karl Popper
he said that a theory is true if you can falsificate it! So it is true when you prove that it is false. Falsification by Popper

these ideas are born for correcting the affirmations of the Vienna Circle, that starting from Wittgenstein's Tractatus, about  the verification (finding proves to confirm a theory) is at the root of the scientific research.  Vienna Circle
Neopositivism

Fine to talk about phylosophy in an ocean of bits 0/1!

Thanks moreover to let me correct my IMProbale IMP library.
Reply


Messages In This Thread
IMP - Not this old chestnut again - by Dimster - 10-16-2024, 02:57 PM
RE: IMP - Not this old chestnut again - by bplus - 10-16-2024, 04:01 PM
RE: IMP - Not this old chestnut again - by Pete - 10-16-2024, 10:25 PM
RE: IMP - Not this old chestnut again - by TempodiBasic - 10-22-2024, 08:57 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)