theory

Names of HTML form naming conventions

徘徊边缘 提交于 2019-12-05 21:35:22
问题 In Rails and CakePHP1.2, forms tend to include input elements with names like the following: <input name="comment[author]" /> Is there a formal name for the notation used in the "name" attribute? Likewise, in CakePHP1.1 I do believe that the same would have looked like this: <input name="comment/author" /> Again, is there a formal name for the notation used in the "name" attribute? 回答1: in cake php, the naming scheme is in multidimensional array access format, though i'm not really sure what

Example of Call by name

自作多情 提交于 2019-12-05 20:05:07
问题 In my principles of programming class we are talking about different calling methods. Some we discussed were: call by value call by reference call by value/result and call by name I can't find an example of how call by name works. Anyone care to give me an example? I think that when you take an xml file as input this is similar to call by name. Could someone give me a more traditional example? 回答1: I'll work in a hypothetical programming language. Let's assume we have a function p(x) that

Subtracting a large unsigned binary number from a smaller one

最后都变了- 提交于 2019-12-05 18:14:49
问题 I'm taking a computer organization and assembly language course. The written part of our lab this week has a question on it that has me stumped. The question reads... Subtract the following unsigned binary numbers (show the borrow and overflow bits). Do not convert to two's complement. 0101 0111 1101 -1110 1011 0110 -------------- I realize that the answer is -1001 0011 1001 but I'm having a hard time trying to figure out how to borrow to actually perform this subtraction by taking the larger

Probability Theory and Mathematical Statistics

你。 提交于 2019-12-05 15:19:23
概率论 事件的差 \(P(B-A) = P(B)-P(AB)\) 古典概型 可能性相同 个数有限 独立性 乘法公式 \(P(AB) = P(A)P(B|A)\) 推广: \(P(A_1A_2A_3...A_n) = P(A_1)P(A_2|A_1)...P(A_n|A_1A_2...A_{n-1})\) 独立性 若 \(P(A_1A_2A_3...A_n) = P(A_1)P(A_2)...P(A_n)\) 则称 \(A_1,A_2,...,A_n\) 相互独立 独立性相当于:内在没有联系,它们不会影响彼此的发生 推论: 性质1:$P(B) = P(B|A) $ 性质2:这些事情取反也是相互独立,很好证明 全概率公式和贝叶斯公式 全概率公式 \(P(B) = \sum_{i=1}^{n} {P(A_i)P(B|A_i)}\) "全"概率公式, \(P(B)\) 被分解成多部份之和 贝叶斯公式 \(P(A_i |B) = \frac{P(A_iB)}{P(B)}\) \(P(B) = \sum_{i=1}^{n} {P(A_i)P(B|A_i)}\) \(P(A_i |B) = \frac{P(A_iB)}{\sum_{i=1}^{n} {P(A_i)P(B|A_i)}}\) 我们要知道一个概念: \(P(A_i)\) 叫做”先验概率“; 随机变量 离散型随机变量 0-1分布 又名

Shift-reduce: when to stop reducing?

做~自己de王妃 提交于 2019-12-05 11:41:16
I'm trying to learn about shift-reduce parsing. Suppose we have the following grammar, using recursive rules that enforce order of operations, inspired by the ANSI C Yacc grammar : S: A; P : NUMBER | '(' S ')' ; M : P | M '*' P | M '/' P ; A : M | A '+' M | A '-' M ; And we want to parse 1+2 using shift-reduce parsing. First, the 1 is shifted as a NUMBER. My question is, is it then reduced to P, then M, then A, then finally S? How does it know where to stop? Suppose it does reduce all the way to S, then shifts '+'. We'd now have a stack containing: S '+' If we shift '2', the reductions might

How to attach a DataPoint with a Theory?

自作多情 提交于 2019-12-05 10:36:10
问题 @DataPoints public static final Integer[] input1={1,2}; @Theory @Test public void test1(int input1){ } @DataPoints public static final Integer[] input2={3,4}; @Theory @Test public void test2(int input2 ){ } I want that test1 runs with data set input1 - {1,2} and test2 runs with input2 - {3,4}. But currently each test runs with both the data sets {1,2,3,4}. How to bind specific @DataPoints to specific @Theorys 回答1: DataPoints apply to the class. If you have a @Theory method which takes an int,

What is a direct reference?

南楼画角 提交于 2019-12-05 05:48:09
One of the strict mode rules ( Annex C ) states: When a delete operator occurs within strict mode code, a SyntaxError is thrown if its UnaryExpression is a direct reference to a variable, function argument, or function name. So in this code: delete x x is a reference. (I know this because "the result of evaluating an Identifier is always a value of type Reference" ). But is it a direct reference? And, are there other kinds of references? Indirect references? (If not, what's the point of using the word "direct" at all?) Yes, there are different kinds of References ( EcmaScript §8.7 ). The

integer division properties

风格不统一 提交于 2019-12-05 05:21:00
does the following integer arithmetic property hold? (m/n)/l == m/(n*l) At first I thought I knew answer (does not hold), but now am not sure. Does it hold for all numbers or only for certain conditions, i.e. n > l ? the question pertains to computer arithmetic, namely q = n/m, q*m != n , ignoring overflow. Case1 assume m = kn+b (b<n), left = (m/n)/l = ((kn+b)/n)/l = (k+b/n)/l = k/l (b/n=0, because b<n) right = (kn+b)/(n*l) = k/l + b/(n*l) = k/l (b/(n*l)=0, because b<n) => left = right Case2 assume m = kn, left = (m/n)/l = (kn/n)/l = k/l right = kn/(n*l) = k/l => left = right So, (m/n)/l == m/

Print a tree in sorted order using heap properties (Cormen)

烂漫一生 提交于 2019-12-05 05:13:47
I am refreshing on algorithm theory (from Cormen). There is an exercise in the chapter for binary tries that asks: Can the min-heap property be used to print out the keys of an n-node tree in sorted order in O(n) time? Show how, or explain why not. I thought yes it is possible. In the min heap the element in a node is smaller than both its children. So the root of the heap is always the smaller element of all the n elements and the left child of the root is the smaller than all the elements in the left subtree and the right child of the root is the smaller than all the elements in the right

Proving correctness of multithread algorithms

↘锁芯ラ 提交于 2019-12-05 00:44:39
Multithread algorithms are notably hard to design/debug/prove. Dekker's algorithm is a prime example of how hard it can be to design a correct synchronized algorithm. Tanenbaum's Modern operating systems is filled with examples in its IPC section. Does anyone have a good reference (books, articles) for this? Thanks! It is impossible to prove anything without building upon guarentees, so the first thing you want to do is to get familiar with the memory model of your target platform; Java and x86 both have solid and standardized memory models - I'm not so sure about CLR, but if all else fails,