What does the single quote means in C++ Math programming? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
so recently I was reading a book that teach you how to program in C++ and I am at basic math stuff. I'm not a beginner in C++ but I have seen something strange that I can't find on the internet.
It is a math expression: 5*3(6' 4) and it has a single quote on it. I found didn't know what it was so I checked up on the internet for this and I found only that it is referred as prime. But I don't think it solve my problem and I don't know how correct that is.
Thanks in advance.
EDIT: I want to address all people who commented and answered (and those who will to do the same thing)in this post that I HAVE MADE A BIG MISTAKE. The real math expression was: 5*6(6*4) but my friend's book(which I got this expression) was not printed well and it looked like the one I have wrote in the past. I'm really really sorry about this....

C++14 and up allows single quote ' inside integer literals to allow for grouping digits. Thanks to this, 123'456'789 can be used as more readable equivalent to 123456789.
Depending on a country, it may be also used in mathematical (outside of C++) expressions, although Polish people would rather use 123 456 789 and UK people would use a comma AFAIK - 123,456,789. None of these is valid in C++ (or it would yield results far from expected), but it would be reasonable in mathematical text/formula.
Nevertheless, your example still wouldn't compile. There is no operator between 3 and opening bracket (.

Related

Why ^ and $ were choosen to represent beginning and end of line in regex? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Maybe there is some hidden and forgotten by everyone reason why those keys were choosen? In the same vein as this link http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/ explains use of hjkl in vim and ~ in bash, maybe there is some story behind ^ and $? Actually, on the picture in that article, the terminal shown doesn't even have a ^ key.
I'd really appreciate if somebody will tell or show the keyboard layout used by Ken Thompson when he written a version of QED that supported regex. (And if people stop trying to be funny in the comments).
edit:
These are some amasing replies. Even if they are just guesses, they may serve like a great mnemonic material. Thank you! Just wish you didn't put it on hold so fast, maybe some people were too slow to answer.
It's hardly possible to answer this question today because regexps were introduced more than fifty years ago. I may share versions that seem the most reasonable for me.
Dollar sign was symbolizing the end of line yet in ed editor. First practical implementation of RE were introduced namely in ed and derivatives (like QED). And dollar sign was reused. It meant either the end of line or the last line, depending on context. This is more or less clear but the question why dollar sign was initially denoted the end of something yet remains. It ('$') seems to be an "ASCII approximation" of a typographic "end of paragraph" sign.
As for '^' as the beginning of line, it's probably an "ASCII approximation" of Lambda Greek letter which stood for an empty expression in early theoretical works like this: http://www.fing.edu.uy/inco/cursos/intropln/material/p419-thompson.pdf

Regular Expression - At most One Repeated Digit [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am struggling with a homework problem. I have tried this problem for hours literally. I found a similar question here, but it is not exactly my problem.
The homework problem says 1. (20 points) Construct regular expressions for the following languages.
a) All strings of digits with at most one repeated digit.
The only way I see how this is possible would be to exhaustively somehow take care of every possible case. There are 10 different digits, so it's like A LOT of different cases. I think the max length string can be 11, because after 11, you have to have a second repeated digit. So the number of possible combinations is 10^11. I thought even about writing a DFA and just converting it to a regex, but even that seems like it's impossible.
Does anyone have any advice? We aren't allowed to use non-standard regex features, like groups, lookahead, etc. This is just a plain old regex kind of problem.
Response to comment:
It is not binary. I already asked the teacher.
"Commenters, “regular expression” has one well-defined meaning in computer science. Since this is homework, it’s almost certainly that which is meant (and even more so as it talks of “languages”), and not some specific library. There’s no ambiguity here, and no clarification needed." This is basically what we want. The standard regex stuff often used in theoretical CS classes. As far as what we learned in class, I go to USC if anyone is familiar with that and we only barely talked about this at all. We're onto a completely different topic now.

Style and Enumerators [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
So, in the process of taking a data-structures class (in C++), my professor wanted us to manipulate a linked list of playing cards. That doesn't matter however, what I am interested in is why she did not use an enumerator to represent the suites.
In her code, she used strings to hold the suite of a card. This seemed inefficient because she wanted us to sort them based on suite, under the circumstances, it would have been considerably easier if she had used an enumerated type instead of a string. The string did not offer any help either, because in printing the suite, she output a Unicode character, roughly doubling the length of her function, simply because she did not use an enum.
Is there any reason for her to have done this, or does she simply have strange preferences when it comes to code style?
If you really want to know what your professor's reasoning is, you have to ask your professor. I can only speculate.
But if I were to speculate, I would guess that there are two possible reasons why your professor chose to use strings as descriptors for these attributes.
She is trying to keep the code simple and easy for newbie C++ programmers to understand. Whether the means meet the goal is debateable.
(Personal bias alert) Professors and others in academia, with no real-world experience, often do and teach things that I would consider to be highly sub-optimal.
My guess would be that she either had not considered that approach or that she wanted to test your ability to work with sorting strings.
Code examples might help in that they might clarify what she did and what you think she should have done.
The likely answer is that she just didn't think about the problem she was using to demonstrate whatever she is trying to teach you. That is, she wanted you to focus on sorting (for example), and probably took some code written by someone else and just adapted it to that purpose without much thought.

Converting Regular Expressions For Use With VBA [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Forgive me if this seems basic, but I'm new to regular expressions, and I can't seem to find general information that isn't example driven.
Basically, I'd like to know what to keep in mind when converting regular expressions found around the internet for use with vba. Is it as simple as "oh, just change the non-greedy operator to this ...", or is it involved on a level that I really need to find VBA specific expressions, or get better at writing my own.
My specific example involves converting this phone number pattern
^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$
But i'm really more interested in either a general approach, or an affirmation of its futility. Thanks!
Following up on Cor_Blimey and funkwurm's comments, I have used VBScript 5.5 regexes in Office 2003 and Office 2007 VBA with good success. Details here. For anything more complicated than () and [] groups, I have found writing from scratch more effective than trying to modify an existing expression.

Can a regex be used as input method? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I saw somewhere that a regex can be used as an input method, is this possible? How?
I really don't know anything else about that, I supposed that there's a way to procude Strings from a regex and feed an object with that String, again, this is only what I pictured and I don't know if it's even possible.
EDIT
I know I didn't explain myself, I was in a hurry, sorry for that. Well, long story short. Last week I saw an article about regex, and in one paragraph said "regex could be used as input", thats all it said about that, I couldn't find the article again so I think I could ask here.
Thanks for the votes down. Next time I'll make sure to explain correctly my doubts and to not piss someone off...
A regular expression is not an "input method". A regular expression can be used to constrain input though.
A regex can be input, if your users are the sort that live, eat, and breathe regexps (I can't imagine who would do so...), but even so, that regexp won't become the method.
Since a regex is just a string, it is techniclaly possible to use it as either:
a user input to a program (not often, but I hav seen some applications accept them, usually as a form of "advanced" search filtering)
an input parameter to a method call which accepts a string.
Perhaps one of these is the answer you are looking for?