language-theory

Why semicolon is not required after a curled bracket?

只愿长相守 提交于 2019-12-10 02:11:47
问题 I know that a semicolon is required after a statement (I'm talking about Java, C++, and similar languages), but is not required after a curled bracket. Why so? if (a > b) printf("hello!"); // semicolon is mandatory if (a > b) { printf("hello!"); } // semicolon is not required What is the reason? I mean, what is the theory behind this? 回答1: Because curly brackets are used for grouping statements, but they are not statements themselves. 回答2: Because the language is defined as: statement:

Adding Accents to Speech Generation

為{幸葍}努か 提交于 2019-12-07 00:15:08
问题 The first part of this question is now its own, here: Analyzing Text for Accents Question: How could accents be added to generated speech? What I've come up with: I do not mean just accent marks, or inflection, or anything singular like that. I mean something like a full British accent, or a Scottish accent, or Russian, etc. I would think that this could be done outside of the language as well. Ex : something in Russian could be generated with a British accent, or something in Mandarin could

Adding Accents to Speech Generation

眉间皱痕 提交于 2019-12-05 03:23:31
The first part of this question is now its own, here: Analyzing Text for Accents Question: How could accents be added to generated speech? What I've come up with: I do not mean just accent marks, or inflection, or anything singular like that. I mean something like a full British accent, or a Scottish accent, or Russian, etc. I would think that this could be done outside of the language as well. Ex : something in Russian could be generated with a British accent, or something in Mandarin could have a Russian accent. I think the basic process would be this: Analyze the text Compare with a

Why semicolon is not required after a curled bracket?

筅森魡賤 提交于 2019-12-05 00:23:30
I know that a semicolon is required after a statement (I'm talking about Java, C++, and similar languages), but is not required after a curled bracket. Why so? if (a > b) printf("hello!"); // semicolon is mandatory if (a > b) { printf("hello!"); } // semicolon is not required What is the reason? I mean, what is the theory behind this? Because curly brackets are used for grouping statements, but they are not statements themselves. Because the language is defined as: statement: labeled-statement expression-statement compound-statement selection-statement iteration-statement jump-statement

Regular expression for strings with even number of a's and odd no of b's

半世苍凉 提交于 2019-12-03 16:14:15
问题 Im having a problem in solving the problem:- Its an assignment, i solved it, but it seems to be too long and vague, Can anyboby help me please...... Regular expression for the strings with even number of a's and odd number of b's where the character set={a,b}. 回答1: One way to do this is to pass it through two regular expressions making sure they both match (assuming you want to use regular expressions at all, see below for an alternative): ^b*(ab*ab*)*$ ^a*ba*(ba*ba*)*$ Anything else (and, in

What is the theory behind mutable and immutable types?

浪尽此生 提交于 2019-12-03 09:35:13
问题 One of the things that I admire about Python is its distinction between mutable and immutable types. Having spent a while programming in c before coming to Python, I was astonished at how easily Python does away with all the complexities of pointer dereferencing that drive me mad in c. In Python everything just works the way I expect, and I quickly realized that the mutable/immutable distinction plays an important part in that. There are still a few wrinkles, of course (mutable function

Regular expression for strings with even number of a's and odd no of b's

删除回忆录丶 提交于 2019-12-03 05:28:48
Im having a problem in solving the problem:- Its an assignment, i solved it, but it seems to be too long and vague, Can anyboby help me please...... Regular expression for the strings with even number of a's and odd number of b's where the character set={a,b}. One way to do this is to pass it through two regular expressions making sure they both match (assuming you want to use regular expressions at all, see below for an alternative): ^b*(ab*ab*)*$ ^a*ba*(ba*ba*)*$ Anything else (and, in fact, even that) is most likely just an attempt to be clever, one that's generally a massive failure. The

Exactly what is the difference between a “closure” and a “block”?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 00:33:28
问题 I've found that lots of people use the words closure and block interchangeably. Most of these people can't explain what they're talking about. Some Java programmers (even ones from really expensive consultancies) talk about anonymous inner classes as "blocks" and "closures" - but I know this isn't true. (You can't pass mutable variables in from the scope of the method in which they're defined...) I'm looking for: a precise, computer science definition of a block a precise, computer science

Exactly what is the difference between a “closure” and a “block”?

冷暖自知 提交于 2019-12-02 14:08:10
I've found that lots of people use the words closure and block interchangeably. Most of these people can't explain what they're talking about. Some Java programmers (even ones from really expensive consultancies) talk about anonymous inner classes as "blocks" and "closures" - but I know this isn't true. (You can't pass mutable variables in from the scope of the method in which they're defined...) I'm looking for: a precise, computer science definition of a block a precise, computer science definition of a closure and clarification on the difference between the two. I'd really like to see links

Context Free Language Question (Pumping Lemma)

风格不统一 提交于 2019-12-01 00:57:00
问题 I know this isn't directly related to programming, but I was wondering if anyone know how to apply the pumping lemma to the following proof: Show that L={(a^n)(b^n)(c^m) : n!=m} is not a context free language I'm pretty confident with applying pumping lemmas, but this one is really irking me. What do you think? 回答1: Edit: I was totally leading you down the wrong track. That's what happens when I try to help out when I haven't completely solved the problem myself. Ogden's Lemma Suppose L is