syntax

Line-breaking Expression in Python

I am beginner in python and facing this problem. So how i can break the below expression in 2-3 lines totalIncome = (classACost * float(classASeatsSold)) + (classBCost * float(classBSeatsSold)) + (classCCost * float(classCSeatsSold)) Like this. totalIncome = (classACost * float(classASeatsSold)) + (classBCost * float(classBSeatsSold...

jQuery syntax question : ul as variable, remove item?

This is a simple syntax question. I have a ul saved as a variable like this: $list = $("#city_list"); I am later removing some items from the list with this code: $('ul#city_list li#city_' + $id).remove(); How can I do that using the $list variable I created earlier so that I get something like this: $list.('li#city_' + $id).remo...

Why is 'last' called 'last' in Perl?

What is the historical reason to that last is called that in Perl rather than break as it is called in C? The design of Perl was influenced by C (in addition to awk, sed and sh - see man page below), so there must have been some reasoning behind not going with the familiar C-style naming of break/last. A bit of history from the Perl 1....

What is the Correct Javascript Syntax for this

I am trying to call a function within a function. Here is the code var d = function() { s: function() { alert('cool'); } } (); d.s(); This does not work. What am I doing wrong ...

How do I take a reference to an array slice in Perl?

How would you take a reference to an array slice such that when you modify elements of the slice reference, the original array is modified? The following code works due to @_ aliasing magic, but seems like a bit of a hack to me: my @a = 1 .. 10; my $b = sub{\@_}->(@a[2..7]); @$b[0, -1] = qw/ < > /; print "@a\n"; # 1 2 < 4 5 6 7 > 9 10 ...

How do I resolve this syntax error I get when using the Perl conditional operator?

I would like to get solution for a issue on in perl program. $parallel_on=='YES'? my $pid = $pm->start and next; :0; I want being the statement like this. but I am not getting solved. Can please any one solve this? ...

Is there a Static Constrctors/Destructors Help topic

I know in D2010 they have added support for static constructors and destructors. Where I can find more information about they: syntax and samples? ...

Variable Argument Lists in C++/CLI

How do I create a function which accepts a variable argument list in C++/CLI? I am looking to create a function which forwards most of it's arguments to String::Format. ...

Is there a syntactic sugar C# property syntax to instantiate generic collections?

The following program will fail because Contracts is not instantiated. Of course I can instantiate it in my constructor but if I have dozens of properties and/or multiple constructors I have to keep track of which are instantiated, etc. And of course I could create large blocks for these properties with full gets and sets and private f...

/regex/(string) considered harmful?

In javascript you can match regular expression with regex(string) syntax. However the syntax isn't very used as far as I know, anybody know why? ...

SQL Query Designer

I am wondering what the best (free preferred) sql query designers tools for Windows Vista are? I am looking to create quite complicated INSERTS and UPDATES that involves joins etc and being a SQL beginner would like to use a tool to help design my queries a bit faster. Thanks ...

How do I call a function name that is stored in a hash in Perl?

I'm sure this is covered in the documentation somewhere but I have been unable to find it... I'm looking for the syntactic sugar that will make it possible to call a method on a class whose name is stored in a hash (as opposed to a simple scalar): use strict; use warnings; package Foo; sub foo { print "in foo()\n" } package main; my %...

Ruby Equivalent of C# 'using' Statement

I've been getting into Ruby over the past few months, but one thing that I haven't figured out yet is what the Ruby equivalent of C#'s (and other languages) using statement is. I have been using the require statement to declare my dependencies on Gems, but I am getting lazy and would prefer to not fully qualify my frequently used class ...

Invalid Token when using Octal numbers.

Hi, I'm a beginner in python and I'm trying to use a octal number in my script, but when I try it, it returns me that error: >>> a = 010 SyntaxError: invalid token (<pyshell#0>, line 1) >>> 01 SyntaxError: invalid token (<pyshell#1>, line 1) There's something wrong with my code? I'm using Python3 (and reading a python 2.2 book) ...

F# explicit match vs function syntax

Sorry about the vague title, but part of this question is what these two syntax styles are called: let foo1 x = match x with | 1 -> "one" | _ -> "not one" let foo2 = function | 1 -> "one" | _ -> "not one" The other part is what difference there is between the two, and when I would want to use one or the other? ...

Creating an object of the type a static method is called on in an inheritance chain in C#

I am trying to do something like this in C# public class ParentClass { public static ParentClass GetSomething() { var thing = new // ????? return thing; } } public class ChildClass : ParentClass { } And then I want to be able to call the static method on the child class like so: ChildClass blah = ChildClass.GetSomethin...

PHP MySQL fails whenever WHERE statement is present

I am trying to make a simple query to a small MYSQL table, but when I insert the Where clause, I suddenly get an invalid query error (added a while(mysql_fetch_array ){} when working without the where). The MYSQL console gives a 1064 (syntax) error, however, I checked the MYSQL documentation and I am using the proper syntax as far as I c...

F#: always "unexpected 'when' keyword"

The VS2010 Beta 2 F# compiler always complains about my usage of the when keyword, even when using copy-pasted code which is supposed to work, such as either of these snippets. For instance, this is the error I get when trying to execute a very trivial expression: "Error FS0010: Unexpected keyword 'when' in expression. Expected '->' or ...

Simple math statements in bash in a for loop.

Hi. I'm quite new to bash scripting and usually avoid it all costs but I need to write a bash script to execute some simple things on a remote cluster. I'm having problems with a for loop that does the following: for i in {1..20} do for j in {1..20} do echo (i*i + j*j ) **.5 <--- Pseudo code! done done Can you hel...

VisualBasic 2010 Syntax Refresher

With Parallels and WinXP installed, I thought I'd put VisualStudio back on my computer and tinker around a bit, but it's been a while and I'm a bit rusty with it. Can someone refer me to a quick and easy guide to VBasic syntax? ...