Why does parseInt yield NaN with Array#map?

Why does parseInt yield NaN with Array#map?

From the Mozilla Developer Network:[1,4,9].map(Math.sqrt)will yield:[1,2,3]Why then does this:['1','2','3'].map(parseInt)yield this:[1, NaN, NaN]I have tested in Firefox 3.0.1 and Chrome 0.3 and just as a disclaimer, I know this is not cros

How to concatenate twice with the C preprocessor and expand a macro as in “arg ## _ ## MACRO”?

How to concatenate twice with the C preprocessor and expand a macro as in “arg ## _ ## MACRO”?

I am trying to write a program where the names of some functions are dependent on the value of a certain macro variable with a macro like this:#define VARIABLE 3#define NAME(fun) fun ## _ ## VARIABLEint NAME(some_function)(int a);Unfortunat

When a function has a specific-size array parameter, why is it replaced with a pointer?

When a function has a specific-size array parameter, why is it replaced with a pointer?

Given the following program,#include using namespace std;void foo( char a[100] ){ cout << "foo() " << sizeof( a ) << endl;}int main(){ char bar[100] = { 0 }; cout << "main() " << sizeof( bar ) << endl; foo( bar ); r

From an array of objects, extract value of a property as array

From an array of objects, extract value of a property as array

I have JavaScript object array with the following structure:objArray = [ { foo: 1, bar: 2}, { foo: 3, bar: 4}, { foo: 5, bar: 6} ];I want to extract an array containing the values of key foo, resulting in a value of [ 1, 3, 5 ].I have accom

What is the most effective way for float and double comparison?

What is the most effective way for float and double comparison?

What would be the most efficient way to compare two double or two float values?Simply doing this is not correct:bool CompareDoubles1 (double A, double B){ return A == B;}But something like:bool CompareDoubles2 (double A, double B) { dif

mysqli or PDO - what are the pros and cons? [closed]

mysqli or PDO - what are the pros and cons? [closed]

In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.I prefer PDO fo

What does a “Cannot find symbol” compilation error mean?

What does a “Cannot find symbol” compilation error mean?

Please explain the following about the "Cannot find symbol" error:What does this error mean?What things can cause this error?How does the programmer go about fixing this error?This question is designed to be a comprehensive question about "

Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the re

Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the re

I am trying to do authorization using JavaScript by connecting to the RESTful API built in Flask. However, when I make the request, I get the following error: XMLHttpRequest cannot load http://myApiUrl/login. No 'Access-Control-Allow-Origi

Can I mix MySQL APIs in PHP?

Can I mix MySQL APIs in PHP?

I have searched the net and so far what I have seen is that you can use mysql_ and mysqli_ together meaning:<?php$con=mysqli_connect("localhost", "root" ,"" ,"mysql");if( mysqli_connect_errno( $con ) ) { echo "failed to connect";}else{

mvc upload file with model - second parameter posted file is null

mvc upload file with model - second parameter posted file is null

I have a simple model with 1 string property which I render on a simple view.the view looks like the following:@using (Html.BeginForm("UploadFile", "Home", FormMethod.Post, new { encType="multipart/form-data" })){ @Html.TextBoxFor(m => m

Dispatch.Invoke( new Action…) with a parameter

Dispatch.Invoke( new Action…) with a parameter

Previously I hadDispatcher.Invoke(new Action(() => colorManager.Update()));to update display to WPF from another thread. Due to design, I had to alter the program, and I must pass ColorImageFrame parameter into my ColorStreamManager.Update(

sed: -i may not be used with stdin on Mac OS X

sed: -i may not be used with stdin on Mac OS X

I am using a bison parser in my project. When I run the following command:sed -i y.tab.c -e "s/ __attribute__ ((__unused__))$/# ifndef __cplusplus\n __attribute__ ((__unused__));\n# endif/"I get this errorsed: -i may not be used with stdi

return new RedirectResult() vs return Redirect()

return new RedirectResult() vs return Redirect()

What is the difference between the following two controller ActionResult return statements:return new RedirectResult("http://www.google.com", false);andreturn Redirect("http://www.google.com"); 1:straight from the source// Copyright (c)

ErrorActionPreference and ErrorAction SilentlyContinue for Get-PSSessionConfiguration

ErrorActionPreference and ErrorAction SilentlyContinue for Get-PSSessionConfiguration

My case:$ErrorActionPreference = "Stop";"1 - $ErrorActionPreference;"Get-ChildItem NoSuchFile.txt -ErrorAction SilentlyContinue;"2 - $ErrorActionPreference;"Get-ChildItem NoSuchFile.txt -ErrorAction Stop;"3 - $ErrorActionPreference;"Output:

How to Use -confirm in PowerShell

How to Use -confirm in PowerShell

I'm trying to take user input and before proceeding I would like get a message on screen and than a confirmation, whether user wants to proceed or not. I'm using the following code but its not working:write-host "Are you Sure You Want To Pr

How to increase node spacing for networkx.spring_layout

How to increase node spacing for networkx.spring_layout

Drawing a clique graph with import networkx as nx....nx.draw(G, layout=nx.spring_layout(G))produces the following picture:Obviously, the spacing between the nodes (e.g., the edge length) needs to be increased. I've googled this and found th

Understanding why “pimp my library” was defined that way in Scala

Understanding why “pimp my library” was defined that way in Scala

If I want to add a method to a class in Scala, I need to do something like:class RichFoo(f: Foo) { def newMethod = f.bar()}object RichFoo { implicit def foo2Rich(f: Foo) = new RichFoo(f)}Then f.newMethod will result in creation of RichFoo

How to upload a generic file into a Jenkins job?

How to upload a generic file into a Jenkins job?

I am trying to find a way to prompt the user to select and upload a generic file from a local machine to a Jenkins job prior to build. The input file that user is going to upload is not necessarily a text or a property file.I am specificall

What does “where” mean in a C# class declaration?

What does “where” mean in a C# class declaration?

I tried to google this, but all I could find was documents on ordinary class declarations.public class DataContextWrapper : IDataContextWrapper where T : DataContext, new(){}I see that the class implements IDataContextWrapper, inherits from

Variable template in template class - unexpected error (possible bug?)

Variable template in template class - unexpected error (possible bug?)

Having:struct Value{ template static constexpr T value{0};};(0)ideonetemplatestruct Something{ void x() { static_assert(TValue::template value == 0, ""); }};int main() { Something{}.x(); return 0; } Does not compile wi

assigning class variable as default value to class method argument

assigning class variable as default value to class method argument

I would like to build a method inside a class with default values arguments taken from this class. In general I do filtering on some data. Inside my class I have a method where normally I pass vector of data. Sometimes I don't have the vect

Is there ever a reason to not use the final keyword when catching an exception?

Is there ever a reason to not use the final keyword when catching an exception?

I've seen some code as below in some example BlackBerry Java classes:try{ // stuff that will throw an exception}catch(final Exception e){ // deal with it}I presume the final is for performance. As per the title, since there's rarely (

What is meaning of a pointer to a constant function?

What is meaning of a pointer to a constant function?

Pointers can be declared as pointing to mutable (non-const) data or pointer to constant data.Pointers can be defined to point to a function.My coworkers and I were discussing the use of "const" with pointers and the question came up regardi

Accessing members of a custom data type in Haskell

Accessing members of a custom data type in Haskell

Say I have the following custom data type and function in Haskell:data Person = Person { first_name :: String, last_name :: String, age :: Int } deriving (Eq, Ord, Show)If I

Instagram from Android open on certain user and add caption to uploaded image

Instagram from Android open on certain user and add caption to uploaded image

Instagram for Android is very limited, from what I have seen so far. My scenario is simple: allow the user to edit a picture and when he clicks on Send:Intent share = new Intent(Intent.ACTION_SEND);share.setType("image/jpeg");Then with quer