expression

Java - computing large mathematical expressions

Hello all, Im facing a scenario where in ill have to compute some huge math expressions. The expressions in themselves are simple, ie have just the conventional BODMAS fundamental but the numbers that occur as operands are very large, to the tune of 1000 digit numbers. I do know of the BigInteger class of the java.math module but am loo...

BODMAS assignment

Hello All, Im working on a problem that goes like this - Implement a function that evaluates an expression consisting of following operands : '(', ')', '+', '-', '*', '/'. Each numbers in the expression could be large (as large as being represented by string of 1000 digits). The '/' (i.e. divide) operand returns the integer quotient. ...

regular expression inside SQL Server

Hi! I need something like this... stored value in DB is: 5XXXXXX [where x can be any digit] and i need to match incoming SQL query string like... 5349878. Does anyone has an idea how to do it? i have also different cases like XXXX7XX for example, so it has to be generic. i don't care to represent the pattern in a differnet way ins...

nHibernate Criteria ---- Use of Expression.sql

I need to do a query which checks a column in a table of type integer. how can i use expression.sql(nHIbernate Criteria API) to get all the rows matches the given number. Thank you, Rey. ...

.Net 4: Easy way to dynamically create List<Tuple<...>> results

For a remoting scenario, the result would be very good to receive as an array or list of Tuple objects (among benefits being strong typing). Example: dynamically convert SELECT Name, Age FROM Table => List<Tuple<string,int>> Question: are there any samples out there that, given an arbitrary table of data (like SQL resultset or CSV ...

Transform LINQ IQueryable into a paged IQueryable using LINQ to NHibernate

Hi! I wanna do something like that public IQueryable GetPaged<TSource>(IQueryable<TSource> query, int startIndex, int pageSize) { return GetSession() .Linq<TSource>() .UseQuery(query) .Take(pageSize) .Skip(startIndex); } So you can put any IQuerable statement and "it become...

Expression to calculate a field within a loop

I basically have a few variables 0 < na < 250 0 < max <= 16 nb = (na + max - 1) / max n has the following characterstics 0 <= i < nb - 1 => n = max i = nb - 1 => n = na - i * max Is there an easy way to do this without the ternary operator? for (i = 0; i<nb;i++) { n = ((i + 1) * max > na ? na - (i * max) : max); } Examples...

Regular Expression for validating DNS label ( host name)

I would like to validate a hostname using only regualr expression. Host Names (or 'labels' in DNS jargon) were traditionally defined by RFC 952 and RFC 1123 and may be composed of the following valid characters. List item A to Z ; upper case characters a to z ; lower case characters 0 to 9 ; numeric characters 0 to 9 - ; dash ...

regular expression for time

I want regular expression for HH:MM:SS AM/PM here HH must be 1-12 only, MM must 60 min, SS as usual (60 sec.) I any have it properly ...? ...

HtmlAgilityPack expression to get this?

Hi I am going through a html string with HtmlAgilityPack. Now what I need to get everything between a tagg. It looks like this. <left> <table>..</table> <table>..</table> <table>..</table> <table>..</table> <table>..</table> </left> Now I use this expression for this task. EDIT: var htmlResult = doc.DocumentNode.Selec...

Java Expression Language : Interpolation?

Greetings, In the webapplication I am developing , I want to do something like follows: I Have a Bean like class Gene{ String geneid; String sequence; .. } // EL expression (sometimes should be simple as "${geneid}" without URL pattern) String exp="<a> href='http://www.ncbi.nlm.nih.gov/pubmed?term=${geneid}' />"; String outputString=...

C#: An item with the same key has already been added, when compiling expression

Ok, here's a tricky one. Hopefully there is an expression guru here who can spot what I am doing wrong here, cause I am just not getting it. I am building up expressions that I use to filter queries. To ease that process I have a couple of Expression<Func<T, bool>> extension methods that makes my code cleaner and so far they have been w...

Is it possible to use Column Properties in Expressions in Powerbuilder?

Say I have a field on a datawindow that is the value of a database column ("Insert > Column). It has conditions in which it needs to be protected (Properties>General>Protect). I want to have the field background grey when it's protect. At the moment, the only way I can work out how to do this is to copy the protect conditional, no matte...

Unexpected behavior of expr

Hi all, It may sound a bit trivial but it actually is quite frustrating: Can anyone explain me this: [~:user$]expr 3 + 2 6 [~:user$]expr 3 / 2 1 [~:user$]expr 3 * 2 expr: syntax error When the man page for expr precisely specifies that ARG1 * ARG2 is arithmetic product of both. Thanks, ...

recursive nested expression in Python

I am using Python 2.6.4. I have a series of select statements in a text file and I need to extract the field names from each select query. This would be easy if some of the fields didn't use nested functions like to_char() etc. Given select statement fields that could have several nested parenthese like "ltrim(rtrim(to_char(base_fiel...

JavaScript expression to generate a 5-digit number in every case

Hey, for my selenium tests i need an value provider to get a 5-digit number in every case. The problem with javascript is that the api of Math.random only supports the genration of an 0. starting float. So it has to be between 10000 and 99999. So it would be easy if it would only generates 0.10000 and higher, but it also generates 0.01...

Repository taking linq expression for filtering

I am considering refactoring a repository I have to improve its flexibility and reduce the method count. Where there are the following methods: Collection GetAllUsersByRole(Role role) User GetUserByuserName(string userName) ...I would like to have a single method taking a Linq expression: ICollection GetUsers(Expression e) { //ret...

How to retrieve ordering information from IQueryable object?

Let's say, I have an instance of IQueryable. How can I found out by which parameters it was ordered? Here is how OrderBy() method looks like (as a reference): public static IOrderedQueryable<T> OrderBy<T, TKey>( this IQueryable<T> source, Expression<Func<T, TKey>> keySelector) { return (IOrderedQueryable<T>)source.Provider.Crea...

Confirming Greenspun's 10th Law in C#

I am trying to implement an infrastructure in C# that would allow me to make arbitrary mathematical expressions. For example, I want to be able to take an expression like asin(sqrt(z - sin(x+y)^2)) and turn it into an object that will allow me to evaluate it in terms of x,y, and z, get derivatives, and possibly do some kind of symbolic...

Need a regular expression to trim a css file of all values, just keep selectors

Used to have this but lost it. Could someone assist? Its a short reg expression that I pasted into TextMates search replace to trim a css file in this way. It finds all text between {} and removes it. selector { value: blah; } Becomes.. selector {} Its so i can clean a css file out ready for theming from scratch. Thanks ...