PDA

View Full Version : Any, Some, All, Neither|Nor, None to fix & improve.



ReneMiner
23-03-2021, 19:53
Actually Any is not documented to do what it does. And Some only does what Any should do while there is no complain about All.
Neither|Nor are not available and None is missing.

Talking about keywords here, today:
Keywords for serial logic tests that evaluate to boolean
:D

From point of logic view:

Function Any(cond1, cond2,[...]) works correct but its not documented in the help that it works like this. It returns TRUE if Any condition within the list of test evaluates to TRUE. the advantage over comparison using Or is that it instantly stops testing and returns TRUE if Any tested the first condition that came to result TRUE. The user should look to have the order of tests in a way that the ones to turn out true most likely are first while the ones that rarely come out to be true are to test last.

Any only is mentioned to allow variadic amounts of multiple function parameters in thinBasic while ellipsis ("...") is possible only for the last parameter in freebasic. for that no additional parenthesis are necessary therefore.

Function Some(cond1,cond2,cond3[,...]) works as described but thats the way ANY works.
Some implies to be multiple items so it should return True from 2nd test that resulted true and give the information: yes 2 or more of the conditions to test were true. Else Some were just an Alias of Any.
Some, Any and All are present. Keyword All works primissiomo, niente lamentationes .

But -you know from RegEx-experience certainly the fastest way to find a match ist most likely to sort out what it must not be.
A greedy dot "(?ismx) .*?(?=X)" will miss the first X and try to stay in race, will even repeat matches mutliple times if can look back "(?<=^)" by searching for long ways while a lazy bracket goes along as long it does not meet the evil" [^X]*" :scare:
Thats why i would suggest
None(cond1,cond2[,...]) that goes through all tests to return True then and instantly stop if the first evaluates to true and returns False as a counter/function to All() and
Nor or Neither(cond1, cond2, cond3,[...]) would return True if 2 or more tests came out to be false to be the counter-test for Some().
Some and Neither both can skip the last test if not tested 1 already to meet the condition.


More serial boolean testing? Even without the need of additional keywords - already have plenty of them undocumented - and you know how many we have already...

Its a stress- and quality-test that i perfom on every text-editor that provides syntax highlighting. Any lexer that can handle
all thinBasic-keywords without to faint while windows explains "is not responding" is worth to look at a second time.
Btw. thinAir also should have a timeout for the lexer and Codetipps should not open the help if clicked , try to open in a saftey-distance away from mouspointer and never cover the column nor the row where is the caret (cursor)

Back to topic:

think to have MIN and MAX involved. currently these keywords are functions that return the lowes or highest number in a list of numbers. means they must have at least 2 parameters ...
MinMax expects 3 parameters - not less...

And we have 2 boolean tests:

IsTrue() and IsFalse()

- both test 1 condition only and do not expect a keyword to follow but some expression to evaluate and return Boolean.. Without to add another keyword we could
have these combined to



If isTrue Min 3 [* In] (Cond1, cond2,...)
If IsTrue Max 4 [* In]( cond1, cond2,...)
if isTrue MinMax 2,4 [* In](cond1,cond2,...)


the multiplicator * and keyword In added looks optional but it were another test without Min, Max and MinMax to test an exact number out of a list/ it just has to test all conditions.
Always
If IsTrue 7 * In(cond1, cond2,...)