Is there a way to calculate math expressions like (2-3/4*12) in a different way than presented here?
http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx
Hi,
I am looking at using BDD, however, when evaluating the stories/conditions I write (using nBehave), how do I check if the story passes? Do I write another library with test methods?
For example, if I want to test a site for having a link called "About", do I write a method which can check this and then another method in another class library which can call the method to check the link via lambda syntax and add the relevant test and bdd attributes?
Thanks
Hi I want to delete a line using sed if it matches 2 regular expressions in the same line. EG the line starts with /* and end with */ (comment). The following script will do most of that.
sed -e '/^\/*/ d' -e '/*\/$/ d' filename
This script will remove all lines that start with * and end with */. I want it to remove the line only if is meets both criteria not one.
Is there a simple way to recursively find all files in a directory hierarchy, that do not end in a list of extensions? E.g. all files that are not *.dll or *.exe
UNIX/GNU find, powerful as it is, doesn't seem to have an exclude mode (or I'm missing it), and I've always found it hard to use regular expressions to find things that don't match a particular expression.
I'm in a Windows environment (using the GnuWin32 port of most GNU tools), so I'm equally open for Windows-only solutions.
Is there any benefit in using compile for regular expressions in Python?
h = re.compile('hello')
h.match('hello world')
vs
re.match('hello', 'hello world')
[It seems odd this doesn't exist, so apologies in advance if it's a duplicate]
I want to test for logical equality in C. In other words, I want to know whether two values would be equal if both were converted in the normal way associated with logical expressions.
In C99, I think that
(bool)a == (bool)b
gives what I want. Is that correct? What is the normal way of writing this in traditional C?
I recently saw a video about Erlang on InfoQ,
In that video one of the creators presented how to replace the behavior of a message loop.
He was simply sending a message containing a lambda of the new version of the message loop code, which then was invoked instead of calling the old loop again.
Is that code hot swapping in Erlang reffers to?
Or is that some other more native feature?
Am I right in thinking I can't put an if-statement and the corresponding else-statement on one line in Python?
NB:
variable = value1 if condition else value2
is NOT two statements. It's one statement which can take the value of one of two expressions.
I want to do something like
if condition a=value else b=value
Am I right in thinking this requires a full if-else in Python? Like
if condition:
a=value
else:
b=value
Thanks,
Louise
What's the recommended way of creating a pre-populated two-dimensional array in Scala? I've got the following code:
val map = for {
x <- (1 to size).toList
} yield for {
y <- (1 to size).toList
} yield (x, y)
How do I make an array instead of list? Replacing .toList with .toArray doesn't compile. And is there a more concise or readable way of doing this than the nested for expressions?
Hi,
Anybody know plugins for firefox, which help to write HTML parsers?
it will be nice if plugin allow to test XPath and regular expressions(highlight matched text, cut some parts etc).
Hi,
How can I make a MS-SQL stored function availabe in LINQ expressions if using the Entity framework?
The SQL function was created with CREATE FUNCTION MyFunction(@name) ...). I was hoping to access it similarly to this:
var data = from c in entities.Users where MyFunction(c.name) = 3;
Unfortunately I have only .NET 3.5 available.
class User
has_many :comments
end
class Comment
belongs_to :user
named_scope :recent, :order => 'comments.created_at DESC'
named_scope :limit, lambda { |limit| {:limit => limit}}
named_scope :by_unique_users
end
what would I put in the :by_unique_users so that I can do Comment.recent.by_unique_users.limit(3), and only get one comment per user
Is it currently possible to translate C# code into an Abstract Syntax Tree?
Edit: some clarification; I don't necessarily expect the compiler to generate the AST for me - a parser would be fine, although I'd like to use something "official." Lambdaexpressions are unfortunately not going to be sufficient given they don't allow me to use statement bodies, which is what I'm looking for.
I want to allow the end-users of my web application to modify views (via web based back office), stored in the database.
The desired view engine is expected to be code-injection safe, meaning that the end-user will be limited to the absolute minimum number of expressions available, no server code inserts are allowed.
Is any suitable view engine available to download?
Hello! I apologize if this has been posted before. Compiling under two separate compilers, BCC 5.5 and LCC, yields 0 and 1.
#include <stdio.h>
int main(void)
{
int i = 0, array[2] = {0, 0};
array[i] = ++i;
printf("%d\n", array[1]);
}
Am I to assume not all compilers evaluate expressions within an array from right to left?
I use Pymacs to load Ropemacs and Rope with the following lines in my .emacs as described here.
(autoload 'pymacs-load "pymacs" nil t)
(pymacs-load "ropemacs" "rope-")
It however slowdown the startup of Emacs significantly as it takes a while to load Ropemacs.
I tried the following line instead but that loads Ropemacs everytime a Python file opened...
(add-hook 'python-mode-hook (lambda () (pymacs-load "ropemacs" "rope-")))
Is there a way to perform the pymacs-load when opening a Python file but only if ropemacs and rope aren't loaded yet?
I'm unable to find the .NET FCL built-in concept of precedence to leverage while constructing Expression Trees. Ref System.Linq.Expressions Namespace. Is this something that must be handled manually in code, or is it somehow implicit and I'm not recognizing it, maybe through helper methods or classes?
I want to apply it to math operations to ensure 3 + 5 * 10 results in 53 instead of 80.
Using higher order functions (map, fold or filter) and if necessary lambdaexpressions. Write a definition for f1 and f2 so the following evaluation
is valid:
f1 (f2 (*) [1,2,3,4]) 5
output: [5,10,15,20]
Any help would be appreciated, thanks.
Hey I'm a total n00b at Regular Expressions. I'm wondering if this is the best way to match a string that starts with a private IP address (Perl-style Regex):
(^127\.0\.0\.1)|(^192\.168)|(^10\.)|(^172\.1[6-9])|(^172\.2[0-9])|(^172\.3[0-1])
Thanks much!
Hi,
I'm looking for a way to extract some information from this site via PHP:
http://www.mycitydeal.co.uk/deals/london
There ist a counter where the time left is displayed, but the information is within the JavaScript. Since I'm really a JavaScript rookie, I didn't really know how to get the information.
Normally I would extract the information with "preg_match" and some regular expressions. Can someone help me to extract the information (Hrs., Min., Sec.) ?
Jennifer
Could someone tell me whats a better way to clean up bad HTML so BeautifulSoup can handle it - should one use the massage methods of BeautifulSoup or clean it up using regular expressions?
Thanks.
I'm doing a batch script to connect to a tcp server and then exiting.
My problem is that I can't stop the reactor, for example:
cmd = raw_input("Command: ")
# custom factory, the protocol just send a line
reactor.connectTCP(HOST,PORT, CommandClientFactory(cmd)
d = defer.Deferred()
d.addCallback(lambda x: reactor.stop())
reactor.callWhenRunning(d.callback,None)
reactor.run()
In this code the reactor stops before that the tcp connection is done and the cmd is passed.
How can I stop the reactor after that all the operation are finished?
the following code
Dim dc = New DataColumn(name, GetType(Double), "[col1] ^ [col2]")
produces the following error:
The expression contains unsupported operator '^'.
Is this right, is the power operand not support in datacolumn expressions???
Anyone have an idea how i'd write this?
Regular expressions and I aren't quite good friends.
So here's the really basic operation i'm trying to do using javascript (jQuery framwork that is).
My calculation function return a number, unformated, and i'd like to separate thousands and hundreds by a white space ' '.
I'm sure it's pretty easy for a regexp regular user... but for me...
Thanks for the help.
I'm a newbie to regular expressions and I have the following string:
sequence = ["{\"First\":\"Belyuen,NT,0801\",\"Second\":\"Belyuen,NT,0801\"}","{\"First\":\"Larrakeyah,NT,0801\",\"Second\":\"Larrakeyah,NT,0801\"}"]
I am trying to extract the text Belyuen,NT,0801 and Larrakeyah,NT,0801 in python. I have the following code which is not working:
re.search('\:\\"...\\', ''.join(sequence))
I.e. I want to get the string between characters :\ and \.