I know I can do this:  a = ['1', '2'] b = [] a.forEach(function(e) { b.push(parseInt(e)); }) b &gt;&gt; [1, 2]   I want to learn what is wrong in this?  ['1', '2'].map(parseInt) &gt;&gt; [1, NaN]
1890
From the :  [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 cross-browser functionality (no IE).  I found out that the following will accomplish the desired effect. However, it still doesn’t explain the errant behavior of parseInt.  ['1','2','3'].map(function(i){return +i;}) // returns [1,2,3]
93369
I'm trying to figure out how to make a function that can take an array as a parameter and sort it. I think it is done with positional variables, but I'm not sure.
70618
So I was writing up a simple binary tree in Python and came across [...]  I don't believe this to be related to the Ellipsis object, more it seems to have something to do with an infinity loop (due to Python's shallow copy?). The source of this infinity loop and why it doesn't get expanded while expanding when accessed is something I'm completely lost to, however   &gt;&gt;&gt; a [[[[[], [], 8, 3], [[], [], 3, 2], 6, 3], [], 1, 4], [[], [], -4, 2], 0, 0] &gt;&gt;&gt; Keys(a)#With a+b [0, 1, 6, 8, 3, -4] &gt;&gt;&gt; Keys(a)#With [a,b] [8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...]] &gt;&gt;&gt; Keys(a)[1]#?? [8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...], 8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...]]     Version using a+b  def Keys(x,y=[]):     if len(x):y+=[x[2]]+Keys(x[0],y)+Keys(x[1],y)#Though it seems I was using y=y[:]+, this actually outputs an ugly mess     return y   version using [a,b]  def Keys(x,y=[]):     if len(x):y+=[x[2],Keys(x[0],y),Keys(x[1],y)]     return y   So what exactly is [...]?
16494
When you pass a collection like list, array to another function in python, does it make a copy of it, or is it just a pointer?
1520
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:  for i in range(len(name_of_list)):     name_of_list[i] = something   but I can't remember the name and googling "iterate list" gets nothing.
99253
I like how Java has a Map where you can define the types of each entry in the map, for example &lt;String, Integer&gt;.   What I'm looking for is a type of collection where each element in the collection is a pair of values.  Each value in the pair can have its own type (like the String and Integer example above), which is defined at declaration time.    The collection will maintain its given order and will not treat one of the values as a unique key (as in a map).    Essentially I want to be able to define an ARRAY of type &lt;String,Integer&gt; or any other 2 types.    I realize that I can make a class with nothing but the 2 variables in it, but that seems overly verbose.    I also realize that I could use a 2D array, but because of the different types I need to use, I'd have to make them arrays of OBJECT, and then I'd have to cast all the time.    I only need to store pairs in the collection, so I only need two values per entry.  Does something like this exist without going the class route?  Thanks!
16381
I would want to do something like:  &gt;&gt;&gt; lst = [1, 2, 3, 4, 5] &gt;&gt;&gt; lst.find(lambda x: x % 2 == 0) 2 &gt;&gt;&gt; lst.findall(lambda x: x % 2 == 0) [2, 4]   Is there anything nearing such behavior in Python's standard libraries?  I know it's very easy to roll-your-own here, but I'm looking for a more standard way.
82094
How can I build a loop in JavaScript?
52031
I'm studying on my own over the summer and I'm having a bit of trouble with this question. Also, I don't have any background in this, I haven't taken any classes in this yet so, if you choose to help, please go slow. Thanks. Anyway, here is the problem:   For any set A, finite or infinite, let B be the set of all functions mapping A into the set {0,1}. Show that the cardinality of B is the same as the cardinality of P(A) (power set of A).   Here's what progress I've made. Let f be a mapping from B to P(A). Now I have to show it's injective. Let g,h be elements of B and let x be an element of A:   f(g(x)) = f(h(x))  g, h are elements of B and B maps x to {0,1}. If g(x) = h(x) = 1 or g(x) = h(x) = 0 then we are done. But what about the possibility of g(x) = 1 and h(x) = 0 or vice-versa. How do I deal with that possibility?
44787
If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library.  I have always used Lists for 1d arrays.  What is the reason or circumstance where I would want to use the array module instead?  Is it for performance and memory optimization, or am I missing something obvious?
23825
I got an anonymous type inside a List anBook:  var anBook=new []{  new {Code=10, Book ="Harry Potter"}, new {Code=11, Book="James Bond"} };   Is to possible to convert it to a List with the following definition of clearBook:  public class ClearBook {   int Code;   string Book;  }   by using direct conversion, i.e., without looping through anBook?
29178
I have the following code:  if ($_POST['submit'] == "Next") {     foreach($_POST['info'] as $key =&gt; $value) {         echo $value;     } }   How do I get the foreach function to start from the 2nd key in the array?
7849
See the following MWE to understand what I mean better.  \documentclass[preview,border=12pt]{standalone} \usepackage{pgffor,multido} \begin{document} \section*{foreach} \foreach \ix in {0,1,...,3}{%     \foreach \iy in {0,1,...,\ix}{(\ix,\iy)\ }\endgraf}  \section*{multido} \multido{\ix=0+1}{4}{%     \multido{\iy=0+1}{\the\numexpr\ix+1\relax}{(\ix,\iy)\ }\endgraf} \end{document}     Why cannot \foreach \x in {0,1,...,0}{} discharge the second iteration?
36280
Specifically, with a SortedMap&lt;Vector&lt;String&gt;, int&gt; I get "dimensions expected after this (int) token." Help!
45310
Is there a built in function in .NET 2.0 that will take two arrays and merge them into one array?  The arrays are both of the same type. I'm getting these arrays from a widely used function within my code base and can't modify the function to return the data in a different format.  I'm looking to avoid writing my own function to accomplish this if possible.
27564
The code below generates:    What I expect is:    Why does the \foreach seem to treat the entire list as one value? How do I fix it?  \documentclass{article} \usepackage{xparse} \usepackage{xstring} \usepackage{etoolbox} \usepackage{expl3} \usepackage{tikz}  \begin{document}  \ExplSyntaxOn  \DeclareDocumentCommand{\separate}{m} {   \StrLeft{#1}{1}[\head]   \StrBehind[1]{#1}{\head}[\tail]   \IfInteger{\tail}{\head,\separate{\tail}}{\head} }  \DeclareDocumentCommand{\map}{m} {   \def\list{#1}   \foreach \i in \list   {     [\i]   } }  \ExplSyntaxOff  \def\arg{3669887}  \arg  \separate{\arg}  \map{\separate{\arg}}  \end{document}
20930
I would like to filter an array of items by using the map() function. Here is a code snippet:  var filteredItems = items.map(function(item) {     if( ...some condition... )     {         return item;     } });   The problem is that filtered out items still uses space in the array and I would like to completely wipe them out.  Any idea?  EDIT: Thanks, I forgot about filter(), what I wanted is actually a filter() then a map().  EDIT2: Thanks for pointing that map() and filter() are not implemented in all browsers, although my specific code was not intended to run in a browser.