-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional math operator equal[] #3781
Comments
Hi @AnthonyMuscio there's some existing discussion on this in #2253 I do intend to add the full set of comparison operators. We need to figure out:
|
Thanks for the reference to the earlier discussion Not with sanding there may be issues therein, the environment has changed since that was raised. With the maths operators foreshadowed and other enhancements to the Filter Operators since the original request. As in my example I would favour non-empty vs. empty value because it allows the use of ~[[else]] , if it was yes or no true or false,. you then need to code the next step, how to respond to the result. Case may be handled by
AND a useful one
Actually is:parm[value] implies empty value or not give the way filters work. Perhaps my proposed "is" operator extensions could be provided alongside equals[] or value[] as proposed which meets the requirements of the other issue a bit closer. I think value[] is best if it is numbers and strings, but people will be looking for "equals". |
Even is:sentence ? And one asks do we have a filter to make a title/value upper/lower/sentence We could use such an operator to ignore case by converting to lower before testing rather than build in a case sensitive option. If relevant build case insensitivity into the filter logic not into an operator makes it more reusable. Regards text:loweris[lowecasetest] |
Hi @AnthonyMuscio I don't think we can really overload the "is" operator like that. Think about how complicated it would make the documentation. |
PR #3760 is an attempt on an equals[] and !equals[] filter but it's numeric only |
The reveal-widget is able to compare values: https://tiddlywiki.com/#RevealWidget |
Mario, I looked, can it compare variables? I so often have values in variables by reveal seems to need state tiddlers or text references at best. Is this a missing feature? |
To be clear I am looking for the functionality, not the specific adoption of the above suggestions. I think I could easily make the documentation legible. But I do not know about other "overload" issues. a key fact is it would approach everyday English and be easier to understand. Is resembles an "if" only "is" implies exist or not. so is:upper Would it be too bold to introduce the if:test[value] operator on this? "[!is[system]!if[tiddlername]]" vs "[!is[system]] -[[tiddlername]]" "[!is[system]if:upper[]]" The Thing "is" the is operator. for me at least is not that used beyond [!is[system]] and is:parm[value] is a substantially different form and will be used to test numbers and strings "is:foo[bar]" vs "is[tiddlertype]" It also follows the Regards |
What are valid numbers for you? eg: |
Mario, If I look at the current proposed maths operators simple integer +- and floating point with limited precision would be enough. After all this will be what 98% of users will require. 0-9 . - + may be enough Calc, evans formulae and other maths plugins should cover the rest of the requirements. This is all I have seen so far negate - negation Regards |
PS I am looking forward to play with ceil - smallest integer greater than or equal to a given number |
Form my point of view this is clearly plugin territory. Doing some simple math is easy. ... but as soon as you start to calculate with money, the trouble starts. ... It needs to be precise!!! eg:
I think. If I want to have statistic functions in the core, it has to be right. Otherwise we will only have trouble. |
I would still like an equals test operator but given the aforementioned issues I will leave it to others to address the broader use cases. What about I have found an acceptable method when testing fields, but not titles in a filter.
But given the above since, testing the fields in the current tiddler is common Could we collapse Another example for the record
|
This result is an artefact of the calculation, and need not have anything to do with a comparison. If the proposed change to the $view widget was done we could say <$view value=<> format="0.00"> then "[equals[0.30]]" Regards |
Mario,
Not if it is it only doing a string comparison, my key use case.
This result is an artefact of the calculation, and need not have anything to do with a comparison. If the proposed change to the $view widget was done we could say <$view value=<> format="0.00"> then "[equals[0.30]]" This is why I originally suggested is[value] Regards |
This was fixed with #4554 |
Thanks Jeremy, Lovely work |
Is there already a way in the maths operators proposed that allows us to test a simple value?
[minor edits done]
I think this is not only essential but it would simplify a lot for users, and support the other maths operators.
If it were possible is[3] or is[yes] would be great for unreserved names defined in https://tiddlywiki.com/#is%20Operator
One method to separate from the normal is operation would be
is:value[anumber] and if it contains a non matching or non number no result is returned, 0 is valid blank is not. This could also be used to test the value is a number for input testing.
is:string[anumberorstring] and if it contains matching any thing the value is returned
Of course we would hope
I currently have the following working in pre-release. It tests a tiddler title matches a w3w.co geolocation address.
filter="[<currentTiddler>>prefix[///]!prefix[.]!suffix[.]split[.]count[]prefix[3]suffix[3]]"
but
filter="[<currentTiddler>>prefix[///]!prefix[.]!suffix[.]split[.]count[]is:value[3]]"
or
filter="[<currentTiddler>>prefix[///]!prefix[.]!suffix[.]split[.]count[]equal[3]]"
Would be better
I also see a range of novel uses with the else ~ and title, which resembles a CASE or parse statement
filter="<n> [is:value[2]title[two]] ~[is:value[2]title[two]] ~[is:value[3]title[three]]"
filter="<n>[is:value[2]lookup[$:/number/]] ~[is:value[2]lookup[$:/number/]] ~[is:value[3]lookup[$:/number/]]"
The text was updated successfully, but these errors were encountered: