Hi everyone,
I want to subclass the list type and have slicing return an object of the descendant type, however it is returning a list. What is the minimum code way to do this? If there isn't a neat way to do it, I'll just include a list internally which is slightly more messy, but not unreasonable.
Thank you!
Edit: My code so far:
c...
What would be the most pythonesque way to find the first index in a list that is greater than x?
For example, with
list = [0.5, 0.3, 0.9, 0.8]
The function
f(list, 0.7)
would return
2.
...
Hey guys,
sorry to overflow with so many questions.
I have the following:
(defun recursive-function (string) "returns list of strings"
;I am trying to return flat list
; create list L
(append (mapcar 'recursive-function L)))
But since recursive-function returns a list, I end up with a list of a list of a list..., whereas I want just ...
I am trying to split out what I originally wanted in a single form. The downside was that I wanted to keep multiple lists and I found that I could not use a single form with multiple lists.
What I am trying to do is to keep my customer information in a separate list/form so I can re-use it in a different application as well.
What I wo...
I have 2 classes
public class Customer{
...
public String getCustomerNumber();
...
}
public class Applicant{
....
private Customer c;
public Customer getCustomer(){ return c; }
...
}
When presented with a list of customers or applicants I want a function which iterates the list and does something with the CustomerNu...
I want to truncate absolute values below an epsilon to 0, e.g.,
Truncate[{-3, -2, -1, 0, 1, 2, 3}, 1.5] -> {-3, -2, 0, 0, 0, 2, 3}
I guess I could write a function using Scan[] and If[], but is there a more idiomatic "one-liner" way of doing it in Mathematica?
...
OK, I have this simple function that finds the element of the list that maximizes the value of another positive function.
def get_max(f, s):
# f is a function and s is an iterable
best = None
best_value = -1
for element in s:
this_value = f(element)
if this_value > best_value:
best = element...
i want to problem when i am binding checklistbox in that time i have not require the fields name at run time.
...
Hello,
in my work I use a lot of Venn diagrams, and so far I've been relying on the web-based "Venny". This offers the nice option to export the various intersections (i.e., the elements belonging only to that specific intersection). Also, it does diagrams up to 4 lists.
Problem is, doing this with large lists (4K+ elements) and more t...
Hi a am trying to create a tree using CSS.
In FF works fine , IE6-7 fails.
I have a ul/li structure and inside li i create a table to display the tree row.
On IE i have a gap between li and table.
Here is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional....
Hi everyone. I know this is a beginner question, but I've been banging my head against a wall for two hours now trying to figure this out.
I've got XML coming back from a REST service (Windows Azure Management API) that looks like the following:
<HostedServices
xmlns="http://schemas.microsoft.com/windowsazure"
xmlns:i="http://www....
Is it worthwhile to initialize the collection size of a List<T> if it's reasonably known?
Edit: Furthering this question, after reading the first answers this question really boils down to what is the default capacity and how is the growth operation performed, does it double the capacity etc.?
...
What's a good way to work with many rows in MySql, given that I have a long list of keys in a client application that is connecting with ODBC?
Note: my experience is largely SQL Server, so I know a bit, just not MySQL specifically.
The task is to delete some rows from 9 tables, but I might have upwards of 5,000 key pairs.
I started ou...
If I have this:
a='abcdefghij'
b='de'
Then this finds b in a:
b in a => True
Is there a way of doing an similar thing with lists?
Like this:
a=list('abcdefghij')
b=list('de')
b in a => False
The 'False' result is understandable - because its rightly looking for an element 'de', rather than (what I happen to want it to do) 'd' ...
From http://en.wikipedia.org/wiki/Inode
Unix directories are lists of "link"
structures, each of which contains one
filename and one inode number.
I'd like to just get the length of this list of links, the names of the files in the directory aren't important at this point in my code.
A solution in Perl would be preferred, but ...
Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?
As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let's say I get 3. I'll Take the...
I have a dictionary and a list. The values of the keys match those of the list, I'm just trying to find out how to sort the values in the dictionary by the values in the list.
>>> l = [1, 2, 37, 32, 4, 3]
>>> d = {
32: 'Megumi',
1: 'Ai',
2: 'Risa',
3: 'Eri',
4: 'Sayumi',
37: 'Mai'
}
I've tried using somethin...
What is the best way of implementing multi-level lists/bullets in php?
What I'm trying to implement is a system to take in short phrases, and categorize them within sections. However, at the same time, I would like to have each section to be collapsible and capable of having sub-sections within them.
For Example:
Section 10
Section 10...
I am completely new to Prolog and trying some exercises. One of them is:
Write a predicate set(InList,OutList)
which takes as input an arbitrary
list, and returns a list in which each
element of the input list appears only
once.
Here is my solution:
member(X,[X|_]).
member(X,[_|T]) :- member(X,T).
set([],[]).
set([H|T],[H...
I'm a little confusing when try something like this
b = [lambda x:x**i for i in range(11)]
When I then try b[1](2) I have 1024 as a result that is wrong. But when I write so
b = [(lambda i: lambda x:x**i)(i) for i in range(11)]
all is OK
>>> b[1](2)
2
>>> b[5](2)
32
It works fine but what's wrong in first code?
...