Or Operator in mat-select - angular-material

How do I Use a Or Operator in mat-select, I wish to disable the selection if the values equate to x or y
A Direct Implementation of the OR operator. Defaults to the left Option and Ignores the Right Entirely
<mat-select [disabled]="x.status == 'Cancel' || 'Forfeited' " >
There is no mention in the documents regarding or Usage?

Related

Can I tell clang-format to not add space around arithmetic operators

clang-format seems to always add spaces around operators. For example, the following:
a = b+c
becomes:
a = b + c
Is there a way to tell it not to add spaces around +, -, *, /?
I already know about SpaceBeforeAssignmentOperators (as shown here), I am looking for something similar for operators.
Similar concerns (but with a different direction) in How to add capabilities to clang-format?.

How do you read the "<<" and ">>" symbols out loud?

I'm wondering if there is a standard way, if we are pronouncing typographical symbols out loud, for reading the << and >> symbols? This comes up for me when teaching first-time C++ students and discussing/fixing exactly what symbols need to be written in particular places.
The best answer should not be names such as "bitwise shift" or "insertion", because those refer to more specific C++ operators, as opposed to the context-free symbol itself (which is what we want here). In that sense, this question is not the same as questions such as this or this, none of whose answers satisfy this question.
Some comparative examples:
We can read #include <iostream> as "pound include bracket iostream
bracket".
We can read int a, b, c; as "int a comma b comma c
semicolon".
We can read if (a && b) c = 0; as "if open parenthesis a double ampersand b close parenthesis c equals zero semicolon".
So an equivalent question would be: How do we similarly read cout << "Hello";? At the current time in class we are referring to these symbols as "left arrow" and "right arrow", but if there is a more conventional phrasing I would prefer to use that.
Other equivalent ways of stating this question:
How do we typographically read <<?
What is the general name of the symbol <<, whether being used for bit-shifts, insertion, or overloaded for something entirely new?
If a student said, "Professor, I don't remember how to make an insertion operator; please tell me what symbol to type", then what is the best verbal response?
What is the best way to fill in this analogy? "For the multiplication operation we use an asterisk; for the division operation we use a forward-slash; for the insertion operation we use ____."
Saw this question through your comment on Slashdot. I suggest a simpler name for students that uses an already common understanding of the symbol. In the same way that + is called "plus" and - is (often) called "minus," you can call < by the name "less" or "less-than" and > by "greater" or "greater-than." This recalls math operations and symbols that are taught very early for most students and should be easy for them to remember. Plus, you can use the same name when discussing the comparison operators. So, you would read
std::cout << "Hello, world!" << std::endl;
as
S T D colon colon C out less less double-quote Hello comma world exclamation-point double-quote less less S T D colon colon end L semicolon.
Also,
#include <iostream>
as
pound include less I O stream greater
So, the answer to
"Professor, I don't remember how to make an insertion operator; please tell me what symbol to type."
is "Less less."
The more customary name "left/right angle bracket" should be taught at the same time to teach the more common name, but "less/greater" is a good reminder of what the actual symbol is, I think.
Chevron is also a neat name, but a bit obscure in my opinion, not to mention the corporate affiliation.
A proposal: Taking the appearance of the insertion/extraction operators as similar to the Guillemet symbols, we might look to the Unicode description of those symbols. There they are described as "Left-pointing double angle quotation mark" and "Right-pointing double angle quotation mark" (link).
So perhaps we could be calling the symbols "double-left angle" and "double-right angle".
My comment was mistaken (Chrome's PDF Reader has a buggy "Find in File" feature that didn't give me all of the results at first).
Regarding the OP's specific question about the name of the operator, regardless of context - then there is no answer, because the ISO C++ specification does not name the operators outside of a use context (e.g. the + operator is named "addition" but only with number types, it is not named as such when called to perform string concatenation, for example). That is, the ISO C++ standard does not give operator tokens a specific name.
The section on Shift Operators (5.8) only defines and names them for integral/enum types, and the section on Overloaded Operators does not confer upon them a name.
Myself, if I were teaching C++ and explaining the <</>> operators I would say "the double-angle-bracket operator is used to denote bitshifts with integer types, and insertion/extraction with streams and strings". Or if I were being terse I'd overload the word and simply say "the bitshift operator is overloaded for streams to mean something completely different".
Regarding the secondary question (in the comment thread) about the name of the <</>> operators in the context of streams and strings, the the C++14 ISO specification (final working-draft: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf ) does refer to them as "extractors and inserters":
21.4.8.9 Inserters and extractors
template<class charT, class traits, class Allocator>
basic_istream<charT,traits>&
operator>>(
basic_istream<charT,traits>& is,
basic_string<charT,traits,Allocator>& str
);
(and the rest of the >> operator overload definitions follow)
This is further expanded upon on 2.7.2.2.2:
27.7.2.2.2 Arithmetic extractors
operator>>(unsigned short& val);
operator>>(unsigned int& val);
operator>>(long& val);
(and so on...)
cout << "string" << endl;// I really just say "send string to see out. Add end line."
i++; // i plus plus
auto x = class.func() // auto x equal class dot func
10 - ( i %4) * x; // ten minus the quantity i mod four times x
stdout // stud-out
stderr // stud-err
argc // arg see
argv // arg vee
char* // char pointer
&f // address of f
Just because it's an "extraction" or an "insertion" operator does not mean that is the OPERATION.
The operation is "input" and "output"
They are stream operators.
The natural label would be c-out stream output double-quote Hello world exclamation double-quote stream output endline
This the OPERATION you are doing (the verb)
What the ARM calls the operator is irrelevant in that it is a systemic way of looking at things and we are trying to help humans understand things instead

UltraEdit close matching brace

In most text editors, if you type in a { or " (you get the idea), the editor will automatically enter the opposite character, and put your cursor in between. I noticed that UltraEdit does not do this. Is there any way that I can setup UltraEdit so it will close a matching brace?
UltraEdit for Windows v23.20 introduced features for smart inserting of braces and quotes with Brace auto-completion and String auto-completion.
Brace auto-completion
Brace pairs defined in wordfile are auto-closed when opening brace is typed
If no braces in wordfile, or if file is not syntax highlighted, "()", "{}", and "[]" are used as defaults
Pressing Enter will reposition close brace on separate line while maintaining proper indent levels
Pressing Backspace immediately following auto-completion will remove both opening and closing brace
Typing close brace skips over auto-completed close brace without inserting second brace
Can be disabled for non-highlighted (plain text) files
Can be disabled for comments and strings
String auto-completion
Can be disabled for non-highlighted (plain text) files
Can be disabled for comments
The settings for customization of those two features can be found in configuration at Editor - Braces / strings.
UEStudio v16.20 introduced the same features with same configuration settings as UltraEdit for Windows v23.20.
Former versions of UEStudio, the IDE with UltraEdit as core editing engine, have these features from the beginning which could be customized in configuration at IDE - IntelliTips - Miscellaneous by opening from menu Advanced with a click on menu item Configuration or clicking on ribbon tab Advanced on item Settings.
But versions of UltraEdit for Windows prior v23.20 don't have those features.
However, a non smart insert of { and } with setting caret between can be easily achieved with a macro which has the key pressed to insert { assigned to the macro as hotkey.
How to create one or more new UltraEdit macros saved all together into a single macro file being configured for automatic load on startup of UltraEdit is explained in my answer on Search and replace with term list?
The UltraEdit macro code for { is:
InsertMode
"{}"
Key LEFT ARROW
The same concept can be used for:
a double quote
InsertMode
""""
Key LEFT ARROW
an opening square bracket
InsertMode
"[]"
Key LEFT ARROW
and an opening round bracket
InsertMode
"()"
Key LEFT ARROW
It is also possible to customize the macro for certain file types, for example:
IfExtIs "c"
InsertMode
"{}"
Key LEFT ARROW
ExitMacro
EndIf
IfExtIs "cpp"
InsertMode
"{}"
Key LEFT ARROW
ExitMacro
EndIf
IfExtIs "h"
InsertMode
"{}"
Key LEFT ARROW
ExitMacro
EndIf
"{"
This macro inserts } additionally to { on pressing key for { only when file extension of active file is c, cpp or h (in any case). For all other files just { is entered on pressing hotkey of macro in active mode (insert or overstrike mode).
I suggest for inserting ( with ) an even more smart code for the macro:
InsertMode
"("
IfCharIs 13
")"
Key LEFT ARROW
ExitMacro
EndIf
IfCharIs 10
")"
Key LEFT ARROW
ExitMacro
EndIf
IfEof
")"
Key LEFT ARROW
EndIf
This macro inserts first just (. If next character is a carriage return (decimal value 13) or a line-feed (decimal value 10) or the caret is at end of file, additionally ) is inserted and caret is positioned between the parentheses. In all other cases just ( is inserted into active file.
This enhancement makes it possible to modify a condition like
if(iVar == 1 || iVar == 3)
to
if((iVar == 1) || (iVar == 3))
without getting temporarily
if(()iVar == 1 || iVar == 3)
and
if((iVar == 1) || ()iVar == 3)
It is annoying to require in such cases to press key DEL to delete inserted, but unwanted ) after inserting ( somewhere in the middle of a line.

How can I set priority for custom operators?

How can I set priority for custom operators? (if that is possible)
like * or / has higher priority then + or - I want to add such rule to my operators.
Precedence is decided by the table at the bottom of this page: http://msdn.microsoft.com/en-us/library/dd233228.aspx
In particular the order is :
|,',',||,&,&&,< op, >op, =, |op, &op,&&& , |||, ^^^, ~~~, <<<, >>>,^ op,::,- op, +op,
(binary),* op, /op, %op,** op,prefix operators (+op, -op, %, %%, &, &&, !op, ~op)
From the same page:
F# supports custom operator overloading. This means that you can
define your own operators. In the previous table, op can be any valid
(possibly empty) sequence of operator characters, either built-in or
user-defined. Thus, you can use this table to determine what sequence
of characters to use for a custom operator to achieve the desired
level of precedence. Leading . characters are ignored when the
compiler determines precedence.

Can you grab or delete between parentheses in vi/vim?

Given this line of code in C:
printf("%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32)));
Is there a way to delete or yank from the first bold parenthesis to its matching parenthesis? I thought about df), but that only will get you to just after the 9.0.
Is there a similar way to get vim to grab everything between matching braces, regardless of newlines?
What about dib or di(.
It will delete the inner (...) block where the cursor is.
I love text-object motions and selections!
Various Motions: %
The % command jumps to the match of the item under the cursor. Position the cursor on the opening (or closing) paren and use y% for yanking or d% for deleting everything from the cursor to the matching paren.
This works because % is a "motion command", so it can be used anywhere vim expects such a command. From :help y:
["x]y{motion} Yank {motion} text [into register x]. When no
characters are to be yanked (e.g., "y0" in column 1),
this is an error when 'cpoptions' includes the 'E'
flag.
By default, "item" includes brackets, braces, parens, C-style comments and various precompiler statements (#ifdef, etc.).
There is a plugin for "extended % matching" that you can find on the Vim homepage.
You can read the documentation on % and related motion commands by entering :help various-motions in command mode.
object-select
There is another set of motion commands that you can use in Visual mode to select various text objects.
To solve your specific problem you would do the following:
printf("%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32)));
^
Let's say your cursor is positioned at ^. Enter the following sequence to select the part you are looking for:
v2a)
First v enters Visual mode, then you specify that you want to go 2 levels of parens up. Finally the a) selects "a block". After that you can use d or x to delete, etc.
If you don't want to include the outer parens, you can use "inner block" instead:
v2i)
See :help object-select for the complete list of related commands.
To delete all that is inside a pair of parentheses, you can always issue di( and its derivatives.
Note :
As #porglezomb suggested in his comment, you can use a ("along with") instead of i ("inside") to include the parentheses. So, using da( deletes everything inside ( and ) including ( and ).
Deleting text inside the immediate outer pair of parentheses :
So, for this line of code
printf("%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32)));
^ ^
| |
\_______\___---> Cursor range
assuming that your cursor is inside the above mentioned cursor range, you can issue the following commands :
di( --> Deletes '5.0/9.0'
ci( --> Substitutes '5.0/9.0'
yi( --> Yanks '5.0/9.0'
Deleting text inside the n-th outer pair of parentheses :
To grab everything inside the n-th outer pair of parentheses, just add n before the above command. So, with the same cursor position as above,
2di( --> Deletes '(5.0/9.0) * (fahr-32)'
2ci( --> Substitutes '(5.0/9.0) * (fahr-32)'
2yi( --> Yanks '(5.0/9.0) * (fahr-32)'
3di( --> Deletes '"%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32))'
3ci( --> Substitutes '"%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32))'
3yi( --> Yanks '"%3.0f\t%6.1f\n", fahr, ((5.0/9.0) * (fahr-32))'
You can use d% for deleting and y% for yanking.
Place your cursor on the first parenthesis, then press v%y or v%d.
Try ci[block-surrounder]
In your case, place the cursor anywhere between the 2 parenthesis that you highlighed and try the keys: ci(
As answer of David Norman says,
Place your cursor on the first parenthesis, then press v%y or v%d.
Explanation from http://vimdoc.sourceforge.net/htmldoc/vimindex.html:
tag char note action in Normal mode
------------------------------------------------------------------------------
|v| v start characterwise Visual mode
|%| % 1 find the next (curly/square) bracket on
this line and go to its match, or go to
matching comment bracket, or go to matching
|d| ["x]d{motion} 2 delete Nmove text [into buffer x]
This means it will select everything between and including the two brackets (%) while showing the selection to you visually (v) and then yank/copy y or delete/cut d it. (To the default buffer.)
You can put/paste with p.
Made this answer to "teach myself to fish".

Resources