expression

What does /i at the end of a regex mean?

匆匆过客 提交于 2019-12-18 14:16:14
问题 What is the meaning of /i at the tail of this regex? var time = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i; 回答1: /i stands for ignore case in the given string. Usually referred to as case-insensitive as pointed out in the comment. 回答2: It's, like Sachin Shanbhag already answered the 'ignore case' modifier. So /[a-z]/i is equal to /[a-zA-Z]/ . Check this link for other modifiers. 来源: https://stackoverflow.com/questions/4967369/what-does-i-at-the-end-of-a-regex-mean

How *exactly* does the RHS of PowerShell's -f operator work?

限于喜欢 提交于 2019-12-18 13:39:30
问题 Last time I got confused by the way PowerShell eagerly unrolls collections, Keith summarized its heuristic like so: Putting the results (an array) within a grouping expression (or subexpression e.g. $()) makes it eligible again for unrolling. I've taken that advice to heart, but still find myself unable to explain a few esoterica. In particular, the Format operator doesn't seem to play by the rules. $lhs = "{0} {1}" filter Identity { $_ } filter Square { ($_, $_) } filter Wrap { (,$_) }

Why isn't a final variable always a constant expression?

[亡魂溺海] 提交于 2019-12-18 12:04:32
问题 In the below code: final int a; a=2; byte b=a; // error: possible loss of precision Why do I get this error? Isn't a final variable compile time constant expression and hence implicitly narrowed to byte during the assignment? In other words isn't the above code equivalent to: final int a=2; byte b=a; 回答1: The compiler isn't that smart. We can tell that the value will always be 2. But what if we had something like this? class ABC{ final int a; public ABC(){ if(Math.random() < .5){ a = 2; }

Why isn't a final variable always a constant expression?

。_饼干妹妹 提交于 2019-12-18 12:04:10
问题 In the below code: final int a; a=2; byte b=a; // error: possible loss of precision Why do I get this error? Isn't a final variable compile time constant expression and hence implicitly narrowed to byte during the assignment? In other words isn't the above code equivalent to: final int a=2; byte b=a; 回答1: The compiler isn't that smart. We can tell that the value will always be 2. But what if we had something like this? class ABC{ final int a; public ABC(){ if(Math.random() < .5){ a = 2; }

Using a LINQ ExpressionVisitor to replace primitive parameters with property references in a lambda expression

好久不见. 提交于 2019-12-18 10:54:49
问题 I'm in the process of writing a data layer for a part of our system which logs information about automated jobs that run every day - name of the job, how long it ran, what the result was, etc. I'm talking to the database using Entity Framework, but I'm trying to keep those details hidden from higher-level modules and I don't want the entity objects themselves to be exposed. However, I would like to make my interface very flexible in the criteria it uses to look up job information. For example

Evaluation of the following expression

帅比萌擦擦* 提交于 2019-12-18 09:52:50
问题 The following code snippet: int i=-3,j=2,k=0,m; m=++i && ++j || ++k; can be evaluated using two concepts,I believe: 1.Since ++ operator has greater precedence than the logical operators,so first all increment operators will be evaluted,then && having higher precedence than || will be computed.In this process,k will be incremented. 2.First && operator will be evaluated.For this ++ i and ++j will be computed.Since the result of the && operator is 1,no need to evaluate the ++k.So k will not be

Are the denoted values and the storable values the same?

你。 提交于 2019-12-18 09:46:38
问题 I am self learning some parts of Essentials of Programming Languages . Essentials of Programming Languages defines that the expressed values are the possible values of expressions, and the denoted values are the values bound to variables. and We model memory as a finite map from locations to a set of values called the storable values . For historical reasons, we call this the store. The storable values in a language are typically, but not always, the same as the expressed values of the

Define part of an Expression as a variable in c#

我怕爱的太早我们不能终老 提交于 2019-12-18 06:13:55
问题 I have following code: public class MyClass<T> { Expression<Func<T,bool>> Criteria {get; set;} } public class Customer { //.. public string Name {get; set;} } and use it as following: var c = new MyClass<Customer>(); c.Criteria = x.Name.StartWith("SomeTexts"); Is there any way to define something like this: ? p = x=>x.Customer.Name; var c = new MyClass<Customer>(); c.Criteria = p => p.StartWith("SomeTexts"); I used Expression<Func<T,bool>> to use it as where clause in my linq to entities

AndAlso between several Expression<Func<T, bool>> : referenced from scope

馋奶兔 提交于 2019-12-18 06:09:03
问题 I have 3 predicates, I'd like make an AndAlso between. I found several sample on the board, but can't solve my problem. These predicates are : Expression<Func<T, bool>> I have this code : Expression<Func<T, bool>> predicate1 = ......; Expression<Func<T, bool>> predicate2 = ......; Expression<Func<T, bool>> predicate3 = ......; I create an extension method to make an "AndAlso" : public static Expression<Func<T, bool>> AndAlso<T>( this Expression<Func<T, bool>> expr, Expression<Func<T, bool>>

C fundamentals: double variable not equal to double expression?

孤者浪人 提交于 2019-12-18 05:55:07
问题 I am working with an array of doubles called indata (in the heap, allocated with malloc), and a local double called sum . I wrote two different functions to compare values in indata , and obtained different results. Eventually I determined that the discrepancy was due to one function using an expression in a conditional test, and the other function using a local variable in the same conditional test. I expected these to be equivalent. My function A uses: if (indata[i]+indata[j] > max) hi++;