expression

Parse a list of expressions using pyparsing

喜夏-厌秋 提交于 2021-01-27 21:18:00
问题 I'm trying to use pyparsing to parse simple basic program: import pyparsing as pp pp.ParserElement.setDefaultWhitespaceChars(" \t") EOL = pp.LineEnd().suppress() # Identifiers is a string + optional $ identifier = pp.Combine(pp.Word(pp.alphas) + pp.Optional("$")) # Literals (number or double quoted string) literal = pp.pyparsing_common.number | pp.dblQuotedString line_number = pp.pyparsing_common.integer function = pp.Forward() operand = function | identifier | literal expression = pp

How to convert string in format dd.mm.yyyy to date using SSIS expression?

谁说胖子不能爱 提交于 2021-01-27 20:56:16
问题 I have a date 26.12.2019 (dd.mm.yyyy) in CSV which I'm trying to convert to 2019-12-26 using Derived Column in SSIS. I have used this expression but it does not seem to work. (TRIM([Period Start Date]) == "") ? NULL(DT_DATE) : (DT_DATE)(SUBSTRING([Period Start Date],7,4) + "-" + SUBSTRING([Period Start Date],4,2) + "-" + SUBSTRING([Period Start Date],1,2)) How do I rewrite this expression to produce the correct output with a value of data type? 回答1: When using DT_DATE data type, value is not

dynamically build select clause linq

孤街醉人 提交于 2021-01-27 19:22:28
问题 class someClass { public int Id { get; set; } public string Name{ get; set; } ... public string someProperty { get; set; } } Expression<Func<someClass, object>> selector = null; selector = k => new { k.Id ,k.Name }; var serult = myData.Select(selector); // .Select(p=> new {p.Name , p.Id}) etc. This sample code is working But; Expression<Func<someClass, ???>> createSelector(string[] fields) { ... .... return ... } Expression<Func<someClass, ???>> selector = createSelector({"Name","Id"}); Is

Get parent property from Expression function

柔情痞子 提交于 2021-01-27 05:49:01
问题 So let's say that I have the following classes: public class Model { public AnotherModel InnerModel { get; set; } } public class AnotherModel { public String Value{ get; set; } } Now I have the following function: public static void Foo<T, U>(Expression<Func<T, U>> func) { // Get the property info from func } What I would like to do now is the following: Foo<Model, String>(o => o.InnerModel.Value) Here comes the problem: I know that you can fetch the PropertyInfo from the expression func by

Get parent property from Expression function

若如初见. 提交于 2021-01-27 05:48:29
问题 So let's say that I have the following classes: public class Model { public AnotherModel InnerModel { get; set; } } public class AnotherModel { public String Value{ get; set; } } Now I have the following function: public static void Foo<T, U>(Expression<Func<T, U>> func) { // Get the property info from func } What I would like to do now is the following: Foo<Model, String>(o => o.InnerModel.Value) Here comes the problem: I know that you can fetch the PropertyInfo from the expression func by

How can I include one expression in another expression?

旧时模样 提交于 2021-01-20 07:37:11
问题 I have a DateRange class that I'd like to apply to an IQueryable as a where predicate, automatically using the begin and end dates and automatically using an open or closed interval. public class DateRange { public DateTime? BeginDate { get; set; } public DateTime? EndDate { get; set; } public bool BeginInclusive { get; set; } public bool EndInclusive { get; set; } public DateRange() { BeginInclusive = true; EndInclusive = false; } public IQueryable<T> Apply<T>( IQueryable<T> source,

How can I force a throw to be a statement and not an expression (in a lambda expression)?

≡放荡痞女 提交于 2021-01-20 04:20:19
问题 Starting from C# 7.0 the throw keyword can be used both as an expression and as a statement, which is nice. Though, consider these overloads public static void M(Action doIt) { /*use doIt*/ } public static void M(Func<int> doIt) { /*use doIt*/ } When invoking like this M(() => throw new Exception()); or even like this (with a statement lambda) M(() => { throw new Exception(); }); the M(Func<>) overload is selected by the compiler indicating that the throw is here considered as an expression.

How can I force a throw to be a statement and not an expression (in a lambda expression)?

泪湿孤枕 提交于 2021-01-20 04:19:17
问题 Starting from C# 7.0 the throw keyword can be used both as an expression and as a statement, which is nice. Though, consider these overloads public static void M(Action doIt) { /*use doIt*/ } public static void M(Func<int> doIt) { /*use doIt*/ } When invoking like this M(() => throw new Exception()); or even like this (with a statement lambda) M(() => { throw new Exception(); }); the M(Func<>) overload is selected by the compiler indicating that the throw is here considered as an expression.

How can I force a throw to be a statement and not an expression (in a lambda expression)?

拈花ヽ惹草 提交于 2021-01-20 04:15:28
问题 Starting from C# 7.0 the throw keyword can be used both as an expression and as a statement, which is nice. Though, consider these overloads public static void M(Action doIt) { /*use doIt*/ } public static void M(Func<int> doIt) { /*use doIt*/ } When invoking like this M(() => throw new Exception()); or even like this (with a statement lambda) M(() => { throw new Exception(); }); the M(Func<>) overload is selected by the compiler indicating that the throw is here considered as an expression.

Using ggplot geom_text when combining superscript and variable label that contains < symbol

喜夏-厌秋 提交于 2021-01-05 09:06:08
问题 I am having trouble adding R2 annotations to a faceted plot, where my R2 values are sometimes <0.01 (yes, it's not a good regression). I would like the 2 of R2 to be superscript. I have tried several options but seem to be stymied by the < symbol in my values eg, using the iris data set, I first set up a new data frame with my R2 values previously calculated. The x & y positions are also set up as these are different for every facet (not essential for the iris dataset, but it is for mine)