How do you reverse a string in Ruby? I know about string#reverse. I'm interested in understanding how to write it in Ruby from scratch preferably an in-place solution.
Hello.
I can not find how to implement a design in C++. In the language of Delphi in case the operator can write the following design:
case s[j] of
'0'..'9','A'..'Z','a'..'z','_': doSomeThing();
How can i do the same in c++. Attracts me is the construction type 'a' .. 'z' and etc...
Thank you
How are the below valid and invalid as shown and what do they mean. When would such a situation arise to write this piece of code.
++x = 5; // legal
--x = 5; // legal
x++ = 5; // illegal
x-- = 5; // illegal
Hi,
Today, i lost a lot of time fixing a stupid error in my code. Very simplified, the problem was this:
def f():
return 2
2 == f
I forgot to write the parenthesis in the sentence, so I compared a pointer function with a number.
Ok, my question:
Is there any way to change the interpreter to be more stricted with the code? Show more warnings for example...
Thanks ^^
I'm a beginner and I want to write Java code in eclipse. This program takes two LinkedLists of integers (for example, a and b) and makes a LinkedList (for example d) in which every element is the sum of elements from a and b. However, I can't add these two elements from a and b because they are Objects
Example:
a=[3,4,6,7,8]
b=[4,3,7,5,3,2,1]
------
d=[7,7,13,12,11,2,1]
Hi All
I just installed php 5.3.1 in my linux server and now my old work which i used to write with tags is not working at all..
Please help me out..
How can i resolve this??
Hello,
Im trying to write query in linq
Select UserId, UserNumber
FROM User
where UserNumber in
(Select UserNumber
FROM User
group by UserNumber
having Count(UserId) = 1)
Aby hints ?
In Python 2.x, I'd write...
for i in range(5):
print i,
...to get integers from 0 to 4 printed in the same row. How to do that in Python 3.x, since print is a function now?
Hi
How would I write a selector that would look through say a div of textboxes and find which ones have a value in the textbox(so length would be greater than zero).
Can I do this all in one selector or do I have to get all textboxes then loop through them?
I'm trying to write a code for my computer programming class for a project due Monday, and I'm pretty new to Java, but I'm trying to write a program that will first determine if a number the user inputs is even or odd and then determine if the number is prime or not. I'm not sure if I did the algorithm right or not, so if anyone has any corrections on the program to my algorithm or anything else please say so, but my real issue is that the program is refusing to compile. Every time I try, it says it's having an else without if problem. Here's a link to my command box:
http://s1341.photobucket.com/user/Emi_Nightshade/media/Capture_zps45f9a2ea.png.html
Here's my code:
import java.io.*;
import java.util.*;
public class Lesson9p1_ThuotteEmily
{
public static void main(String args[])
{
Scanner kbReader0=new Scanner(System.in);
System.out.print("\n\nPlease enter an integer. An integer is whole number, and it can be either negative or positive. Please enter your number: ");
long num=kbReader0.nextLong();
if(num%2==0) //if and else with braces
{
System.out.println("Your integer " + num + " is even.");
}
else
{
System.out.println("Your integer " + num + " is odd.");
}
Scanner kbReader1=new Scanner(System.in);
System.out.print("\n\nWould you like to know if your number is prime? Please enter yes or no: ");
String yn=kbReader1.nextLine();
if(yn.equals.IgnoreCase("Yes"))
{
System.out.println("Okay. Give me a moment.");
{
if(num%2==0)
{
System.out.println("Your number isn't prime.");
}
else if(num==2)
{
System.out.println("Your number is 2, which is the only even prime number in existence. Cool, right?");
}
for(int i=3;i*i<=n;i+=2)
{
if(n%1==0)
{
System.out.println("Your number isn't prime.");
}
}
else
{
System.out.println("Your number is prime!");
}
}
}
if(yn.equals.IgnoreCase("No"))
{
System.out.println("Okay.");
}
}
}
If anyone could help me out with this and also any problems I may have made elsewhere in the program, I'd be very grateful! Thanks.
Hi all i need your help !
i wanna write javascript function to change the text Lasvegas in string:
ex: "Hello every one in Lasvegas, come Lasvegas with me", How can i change the text but not change content Lasvegas in start tag and end tag
Just using it as a method parameter is fine but what about an easy way to use it in strings?
For instance say I have this:
11 void myTest()
12 {
13 if(!testCondition)
14 logError("testcondition failed");
15 }
And I want the output to be:
"myTest line 14: testcondition failed"
How can I write logError? Does it have to be some monstrosity of a macro?
Hello,
I´m thinking about writing an android app, but have no experience in programming such apps.
My question is whether it is possible to access the standart message editor of android with my app and add for example additional information to it or would it be neccesary to write a complete new editor which would be started as a seperate app.
greetings
How would I write a SQL query that excludes a record if one (external) record from a one to many join matches a certain condition?
For example:
Details
ID
1
2
Items
DetailID Item
1 A
1 B
2 B
2 C
How would I select the detail records where the Items do not include 'A'?
I'm looking for a function that will accept a string representing the scheme portion of a URL (e.g., "http", "https", "ftp", etc.) and return the standard port. It might be used like this:
echo get_port_from_protocol("http"); // 80
As a last resort, I suppose I could write something to parse through /etc/services (assuming I only need to run under UNIX-like operating systems).
But surely there must be something built-in to PHP, no?
How does one use RegEx in C++?
I suppose there is Boost or PCRE..
But what if I wanted to write my own for color syntax highlighting code opened in an editor?
How would I do this from scratch?
I have a query which is failing, as it needs to be using LEFT JOIN, as opposed to the default INNER JOIN used by the 'join' syntax:
var users = (from u in this._context.Users
join p in this._context.Profiles on u.ProfileID equals p.ID
join vw in this._context.vw_Contacts on u.ContactID equals vw.ID
orderby u.Code
select new { ID = u.ID, profileId = p.ID, u.ContactID, u.Code, u.UserName, vw.FileAs, p.Name, u.LastLogout, u.Inactive, u.Disabled }).ToList();
How would i re-write this so that is utilises a LEFT join?
instead of using getParameterByName('Field', PostData) (PostData == $('form').serialize();)
I would like to write PostData.Field, how can i do that with javascript?
I have to write a simple method extractArticle() that returns Article object which is extracted from Message object. I have MessageService and ArticleService classes intended to handle tasks like this. What service class is more correctly to use to incapsulate extractArticle() funcionality?
$article = MessageService::extractArticle(Message $message);
or
$article = ArticleService::extractArticleFromMessage(Message $message);
Hi all,
Looking for a creative way to be sure values that come from the getHours, getMinutes, and getSeconds() method for the javascript Date object return "06" instead of 6 (for example). Are there any parameters that I don't know about? Obviously I could write a function that does it by checking the length and prepending a "0" if need be, but I thought there might be something more streamlined than that.
Thanks.
I need to write a C program that has a parent and n children that act as follows:
Parent process:
Reads a value n from the user
Forks n children
Waits to receive exit code from the first child and prints it
Loops forever
Is there a relatively easy way to display the output of a C++ program on a webpage? And I don't mean manually, in other words, you see it on a webpage as it runs not as in I make a code tag and write it in myself.
Currently have approximately 2000 simultaneouse connections. We average approximately 425 reads and writes per second. We have a read to write ration of 3:1. All of our tables are myisam. Can we expect better or worse performance when we go from mysql 4.1.22 to 5.0?