Loading ...
Sorry, an error occurred while loading the content.

24033Re: [Clip] VanWeerthuizenian Expressions

Expand Messages
  • flo.gehrke
    Sep 18, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Art Kocsis <artkns@...> wrote:
      >
      > At 9/10/2013 05:11 PM, Flo wrote:
      >> It has been discussed several times that NT doesn't master Boolean
      >> Expressions (cf message #21773)...
      > Flo, If I can jump in here.(...)
      > In testing boolean expressions...

      Thanks for your explanations, Art!

      This is certainly a great help for users trying to go further into that topic.

      However, I would like to get back to my question concerning the specific concept that was introduced by Wayne VanWeerthuizen (where is he?) with his abovementioned 'NoteTab Tutorial Control Structures v003.OTL'...

      > Is anyone (also Wayne himself) still using such expressions and
      > could give us more examples. Regrettably, Wayne's Tutorial was
      > never finished and has remained a highly instructive fragment
      > only. Also, it's lacking complete working examples

      So far, Wayne gave us the solution for only five conditions.

      Given a simple list...

      A B
      A B C
      A C D
      B
      D E F

      we could test Wayne's five expressions against that list with the following clip...

      ^!Set %Lines%=^$GetTextLineCount$
      ^!Set %Row%=1
      ^!Goto ^?{(H=5)Find lines matching...==A AND B|A OR B|A NOT B|A XOR B|NOT A}

      :A AND B
      :Loop_1
      ^!Set %A%=0; %B%=0
      ^!Jump ^%Row%
      ^!IfMatch "^.*A.*$" "^$GetLine$" ^!Set %A%=1
      ^!IfMatch ".*B.*$" "^$GetLine$" ^!Set %B%=1
      ^!If ^$Calc(MIN(^%A%;^%B%))$=1 Next Else Skip
      ^!Set %Hits%=^%Hits%^$GetLine$^P
      ^!Inc %Row%
      ^!If ^$GetRow$ < ^%Lines% Loop_1
      ^!Info [L]Expression: A AND B^P^PMatches:^P^%Hits%
      ^!Goto Out

      :A OR B
      :Loop_2
      ^!Set %A%=0; %B%=0
      ^!Jump ^%Row%
      ^!IfMatch "^.*A.*$" "^$GetLine$" ^!Set %A%=1
      ^!IfMatch ".*B.*$" "^$GetLine$" ^!Set %B%=1
      ^!If ^$Calc(MAX(^%A%;^%B%))$=1 Next Else Skip
      ^!Set %Hits%=^%Hits%^$GetLine$^P
      ^!Inc %Row%
      ^!If ^$GetRow$ < ^%Lines% Loop_2
      ^!Info [L]Expression: A OR B^P^PMatches:^P^%Hits%
      ^!Goto Out

      :A NOT B
      :Loop_3
      ^!Set %A%=0; %B%=0
      ^!Jump ^%Row%
      ^!IfMatch "^.*A.*$" "^$GetLine$" ^!Set %A%=1
      ^!IfMatch ".*B.*$" "^$GetLine$" ^!Set %B%=1
      ^!If ^$Calc(MIN(^%A%;1-^%B%))$=1 Next Else Skip
      ^!Set %Hits%=^%Hits%^$GetLine$^P
      ^!Inc %Row%
      ^!If ^$GetRow$ < ^%Lines% Loop_3
      ^!Info [L]Expression: A NOT B^P^PMatches:^P^%Hits%
      ^!Goto Out

      :A XOR B
      :Loop_4
      ^!Set %A%=0; %B%=0
      ^!Jump ^%Row%
      ^!IfMatch "^.*A.*$" "^$GetLine$" ^!Set %A%=1
      ^!IfMatch ".*B.*$" "^$GetLine$" ^!Set %B%=1
      ^!If ^$Calc(ABS(^%A%-^%B%))$=1 Next Else Skip
      ^!Set %Hits%=^%Hits%^$GetLine$^P
      ^!Inc %Row%
      ^!If ^$GetRow$ < ^%Lines% Loop_4
      ^!Info [L]Expression: A XOR B^P^PMatches:^P^%Hits%
      ^!Goto Out

      :NOT A
      :Loop_5
      ^!Set %A%=0
      ^!Jump ^%Row%
      ^!IfMatch "^.*A.*$" "^$GetLine$" ^!Set %A%=1
      ^!If ^$Calc(1-^%A%)$=1 Next Else Skip
      ^!Set %Hits%=^%Hits%^$GetLine$^P
      ^!Inc %Row%
      ^!If ^$GetRow$ < ^%Lines% Loop_5
      ^!Info [L]Expression: NOT A^P^PMatches:^P^%Hits%
      ^!Goto Out

      :Out
      ^!ClearVariables

      As far as I can see, the clip gets to correct results.

      Nevertheless, for me the question remains: Is there any way to enlarge Wayne's concept to conditions like 'A AND B AND NOT (E OR D)', for example? Or is there no way to get beyond the borders of those five conditions?


      Regards,
      Flo

      P.S. Regarding...

      > Too often help is solicited and answers posted with nary a word
      > of feedback or thanks. That is not a motivator for continuing
      > to offer help.

      How right you are.... :-(
    • Show all 12 messages in this topic