How do I convert this:
[True, True, False, True, True, False, True]
Into this:
'AB DE G'
Note: C and F are missing in the output because the corresponding items in the input list are False.
What is the least amount of code you can write to create, sort (ascending), and print a listof 100 random positive integers? By least amount of code I mean characters contained in the entire source file, so get to minifying.
I'm interested in seeing the answers using any and all programming languages. Let's try to keep one answer per language, edit the previous to correct or simplify. If you can't edit, comment?
Given an IEnumerable<T> and row count, I would like to convert it to an IEnumerable<IEnumerable<T>> like so:
Input:
Row Count: 3
List: [1,2,3,4,5,6,7]
Output
[
[1,4,7]
[2,5]
[3,6]
]
How can I do this using LINQ?
Is there a way for a jQuery function to "skip" an li? Such as Having 3 list items, you click on the 1st one, it calls a next() function, and skips the 2nd li and goes to the 3rd.
Current code is here:
$('ul.gallery li').click(function() {
$(window).scrollTo($(this).next('li'), 800, {easing:'easeOutCirc', axis:'x', offset:-50 } );
});
I want it to skip the immediate li and go to the one after that.
For debug reasons, and curiosity, I wish to list all classes loaded to a specific class loader.
Seeing as most methods of a class loader are protected, what is the best way to accomplish what I want?
Thanks!
As part of a homework assignment in Lisp, I am to use apply or funcall on any predicates I find. My question (uncovered in the coursework) is: how do I know when I've found a predicate in my listof arguments? I've done some basic google searching and come up with nothing so far. We're allowed to use Lisp references for the assignment - even a pointer to a good online resource (and perhaps a specific page within one) would be great!
I am using this animation class to create the animation when i shrink and expand the list on some click event
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.LinearLayout.LayoutParams;
public class ExpandAnimation extends Animation{
private View mAnimatedView;
private LayoutParams mViewLayoutParams;
private int mMarginStart, mMarginEnd;
private boolean mIsVisibleAfter = false;
private boolean mWasEndedAlready = false;
public ExpandAnimation(View view, int duration){
setDuration(duration);
mAnimatedView = view;
System.out.println(view.getVisibility());
mViewLayoutParams = (LayoutParams)view.getLayoutParams();
mIsVisibleAfter = (view.getVisibility() == View.VISIBLE);
System.out.println("mIsVisibleAfter:- "+ mIsVisibleAfter);
mMarginStart = mViewLayoutParams.bottomMargin;
System.out.println("mMarginStart:- "+ mMarginStart);
mMarginEnd = (mMarginStart == 0 ?(0 - view.getHeight()):0);
System.out.println("mMarginEnd:- "+mMarginEnd);
view.setVisibility(View.VISIBLE);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t){
super.applyTransformation(interpolatedTime, t);
System.out.println("mMarginEnd:- "+interpolatedTime);
if(interpolatedTime<1.0f){
System.out.println("Inside if true");
mViewLayoutParams.bottomMargin = mMarginStart + (int) ((mMarginEnd - mMarginStart)*interpolatedTime);
System.out.println("mViewLayoutParams.bottomMargin:- "+mViewLayoutParams.bottomMargin);
mAnimatedView.requestLayout();
}else if(!mWasEndedAlready){
mViewLayoutParams.bottomMargin = mMarginEnd;
mAnimatedView.requestLayout();
System.out.println("mIsVisibleAfter:- "+mIsVisibleAfter);
if(mIsVisibleAfter){
mAnimatedView.setVisibility(View.GONE);
}
mWasEndedAlready = true;
}
}
}
i am using following lines on some click event in my activity class to create the object of my animation class
View toolbar = (View) findViewById(R.id.toolbar1);
ExpandAnimation expandani = new ExpandAnimation(toolbar,500);
toolbar.startAnimation(expandani);
My probem is that when click event occurs, my list expand and then shrink but it must stop when it grows completely and shrink when i click on up image.
please let me know that how my animation class is working. i have also tried myself by using SOP statements which you can see in my animation class.
Hi All,
I want to import contact list from Yahoo and MSN by giving user name and password in Java.
I can do this with Gmail easily. Can anybody give me code sample in Java for this? Any type of help we be appreciated.
Thanks
I am attempting to locate the nth element of a List in Prolog. Here is the code I am attempting to use:
Cells = [OK, _, _, _, _, _] .
...
next_safe(_) :-
facing(CurrentDirection),
delta(CurrentDirection, Delta),
in_cell(OldLoc),
NewLoc is OldLoc + Delta,
nth1(NewLoc, Cells, SafetyIdentifier),
SafetyIdentifier = OK .
Basically, I am trying to check to see if a given cell is "OK" to move into. Am I missing something?
Hello,
I have the following question about JPA:
Can I save the order of the elements in a java.util.List? In my application the order in which I put elements in the Lists is important but after I get those collections from the database the order is not the same (as expected). Can you show me a way to deal with this problem?
P.S. There is not a field in the entities that I put in the collections by which I can order them.
Rosen
I have a class MyClass with a method MyMethod. For every MyClass instance in a listof MyClass instances i want to invoke MyMethod and have them run in a separate thread. I am using .NET 4.0 and the Parallel extensions.
Is it possible that the Android browser renders the HTML list box, such as:
item 1
item 2
item 3
item 4
All
as a dropdown? I can't seem to get it to display a proper multiline listbox. Anyone knows what the trick is?
My question is more like a theoretical.
Say you have an object, that represents the listof something (articles, pages, accounts etc.)
class ObjCollection
You have a class, that represents a specific item in collection:
class objItem
I have a problem thinking of a basic responsibilities of each object.
Which class is responsible for creating a new objItem?
Which class is responsible for deleting a objItem? Should it delete itself as a method?
So far i have this, which prints out every word in my list, but i am trying to print only one word at random. Any suggestions?
def main():
# open a file
wordsf = open('words.txt', 'r')
word=random.choice('wordsf')
words_count=0
for line in wordsf:
word= line.rstrip('\n')
print(word)
words_count+=1
# close the file
wordsf.close()
Hi all,
Happy New Year to all. I'm a newbie in VB.NET and ASP.NET. This is my problem:
I retrieve a listof records from DB and, for every row, I need to show 4 checkboxes. I can use a checkboxlist for every rows, but it's not so clear how I can process the results after the submit.
I've some object and some operations available for that object. From database I extract a listof object with all operations. For every operation I want to show a check box to enable or disable the operation. The result is something like that:
OBJ1 - url - [] [x] []
OBJ2 - url - [] [x] [x]
On url I've an href to another page created using the Id retrieved from DB. To create that I used this code:
<td class="column-filename">
<strong>
<asp:Label runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "GroupName")%>'></asp:Label>
</strong>
</td>
<td align="left">
<span style="vertical-align:middle">
<asp:CheckBoxList runat="server" ID="operations" RepeatDirection="Horizontal" RepeatLayout="Table">
<asp:ListItem Text="View"></asp:ListItem>
<asp:ListItem Text="Upload"></asp:ListItem>
<asp:ListItem Text="Move"></asp:ListItem>
<asp:ListItem Text="Delete"></asp:ListItem>
<asp:ListItem Text="Rename"></asp:ListItem>
<asp:ListItem Text="Replace"></asp:ListItem>
</asp:CheckBoxList>
</span>
</td>
</asp>
</asp>
my problem is: how can I parse all checkboxes?
could you help me or send me a link or any other resources to solve my issue?
many thanks!
Andrea
i want to do some actions when all items in checked list box are unchecked. There is only event ItemCheck but the check state is not updated until after the ItemCheck event occurs.
Hi, I am passing a List as a JRBeanCollectionDataSource to a Subreport, I was wondering how you retrieve the integer value and display on the report. Your help is greatly appreciate.
I have column called "Date Submitted" as Date/time in one of the Custom list in sharepoint 2007.
it always set to today's date and 12AM time instead of that I want to display today's date with current time hh:mm:ss.
I tried creating calculated column TestDate and formula is : =TEXT(([Date Submitted]),"mm dd yyyy h:MM:SS")
result is 04 28 2010 0:00:00 I wanted to be 04/28/2010 10:50:34
Is it possible to achive this?
Thank you
kanta
hi all,
I am wondering what the best approach is for creating a horizontal list with custom buttons. I read there is no native control for that:
I am considering a UIView with a scroll view inside. On this scrollview I visualize my array of button objects.
Any thoughts?
So I have this dictionary:
ScoreDict = {"Blue": {'R1': 89, 'R2': 80},
"Brown": {'R1': 61, 'R2': 77},
"Purple": {'R1': 60, 'R2': 98},
"Green": {'R1': 74, 'R2': 91},
"Red": {'R1': 87, 'Lon': 74}}
Is there any way how I can convert this dictionary into a list like this:
ScoreList = [['Blue', 89, 80], ['Brown', 61, 77],
['Purple', 60, 98], ['Green', 74, 91], ['Red', 87, 74]]
I'm not too familiar with dictionaries, so I really need some help here. Thanks in advance!
I put a list strings as validTypes in velocity. When I do :
#if (${validTypes}.contains("aaa"))
// do something
#end
it throws an error. But when I do :
#foreach (${validType} in ${validTypes})
${validType}
#end
it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin?
Are there any work around without using velocity tools?
Input: I have a LaTeX file, with plain text & math formulas.
Desired output: I want a listof elements, where each element is:
x-coordinate
y-coordinate
font_name
character_id
Basically, I want to take a LaTeX file, r"render it", but instead of printing it / getting an image, I want it to say "okay, you have a Sigma symbol here, then you have a 'x' symbol there, ...)
What's the easiest way to achieve this? (I'm on Linux)
Thanks!
Does anyone know of a Webmail Contact List Importer scripts (ColdFusion, PHP etc) like those used on Twitter and LinkedIn ? I've found some but they are paid for and I want some more bespoke & open.
To clarify a little more I'm not looking for a way to process .csv files :) I'm looking for a bit of code that can logging into gmail, yahoo mail, hotmail, aol and pull out the users address book.