I want a sequence a(1)=2,a(2)=a(1)+1,....a(n+1)=`[a(1)*a(2)*....a(n)]+1`
I used the command
> A = numeric(100)
> A[1] = 2
> A[2] = 3
> for(i in 3:100){
+ A[i]=(A[i-1]-1)*A[i-1]+1; print(A[i]);}
i got the answer only upto i=10 afterthat i got every value "Inf"
[1] 7
[1] 43
[1] 1807
[1] 326344...
I want a sequence a(1)=2,a(2)=a(1)+1,....a(n+1)=`[a(1)*a(2)*....a(n)]+1`
I used the command
> A = numeric(100)
> A[1] = 2
> A[2] = 3
> for(i in 3:100){
+ A[i]=(A[i-1]-1)*A[i-1]+1; print(A[i]);}
i got the answer only upto i=10 afterthat i got every value "Inf"
[1] 7
[1] 43
[1] 1807
[1] 326344...
I've created code for a manu system that can show / hide menus and submenus. Now I wonder if the structure of the code is good enough or if you find something that can be done better?
var initExpanders = function () {
"use strict";
function lsTest(){
var test = 'localstoragetest...
On Code Review we often encounter questions with the same kind of problem over and over again.
Some of us are using the auto comments script which allows you to maintain a list of comments to post.
What are some useful tin-can comments that can be good to have in your list of comments?
If you ...
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
Here is my code...
public class Java {
public static void main(String[] args) {
long start = System.nanoTime();
long sum = 0;
for (int i = 2; i < 2000000; i++) {
bool...
For example, I'm the only person in my company (that has been around for years and is the largest credit company in europe at the moment) who knows how to unit test.
or, at teh very least, in my department. And my department is in charge of all internal apps which drive how our company works. If internal apps dies, the company dies
What that will actually look like is I will browse to X url, fill in Y and Z fields, press the submit button, and then check for elements with the class .error-message.
btw important distinction, TDD is not about making sure every code path has a unit test
it's about making sure every code path has some kind of test
I have a simple function that takes a string and reverses it:
def reverse(string):
begin = 0
end = len(string) - 1
strlist = [i for i in string]
while(begin < end):
temp = strlist[begin]
strlist[begin] = strlist[end]
strlist[end] = temp
beg...
while you want to try and aim for unit tests, some things - such as ui interactions - can't be unit tested and have to be integration tested (i.e, mock out some components)
You see this in most corporations. It's only in the 'bigger tech giant' corps that you actually see that attitude change.
For example, Netflix, Google. They care about the quality of their code. Netflix is unique as well in that most of their code is open sourced
But a lot of corporations still view code as a second rate citizen and view the end result as the first rate citizen (which is altogether understandable. clean code doesn't get customers. good results do)
Yes! Add it to your question. Arguably this question then belongs on the code review site, but I'd leave that to more seasoned c++ people to decide. I'll remove my down vote once you edit the question (it's locked in until the question is edited). — Simon O'Hanlon44 secs ago
Assuming the code works as intended and you want to know how to do achieve the same result, better (for some values of better), feel free to post it on CodeReview — Zak36 secs ago
I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of html. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I have had to remove a few things from the below code which do things like whitespace normalization,...
@DanPantry It's a broad line, when site business is rolling, they're all off-topic, but when it starts getting a bit... personal, it's kinda frowned upon by some
I would like to know what the difference is between
window.setTimeout(myFancyFunciton, 1000);
and
setTimeout(myFancyFunciton, 1000);
Both seem to do the exact same thing. When should you use one or the other?
I am currently done with this little rock, paper, scissors, lizard, Spock game in jquery. The game is working fine but I am not pleased with the code. Is there a way to refactor this else/ if statements? I was thinking maybe about ternary operators and I tried doing so but failed. This is basical...
Hello I am new to Java Swing so decided to create a calculator to learn some of the basic however I would like someone to look over my code to see if they can give me any improvements?
I have 6 classes and 2 interfaces I have chosen to split the communication of both operators and digits the mai...
Some background info:
Creating a user booking system.
I am trying to make a table quickly that will allow me to select an element within a table, and it will book it so it can't be selected by another user (if booked).
I am trying to create a big table 8x15 in php
i.e.
echo "<table border='1'>"...
Lately I've started wondering about the ¤ character which is shift+4 on my Norwegian keyboard (it's also present on several others, including the U.S. International keyboard layout). I've never seen a use for it, yet for some reason someone decided it was important enough to have it put in such a...
Must you do it in Clojure? On the JVM, you can do it in Java or any other accessible JVM language. If it must be Clojure, show us a solution in your language of choice. Finally, you might be better to post in CodeReview. — Thumbnail45 secs ago
@Thumbnail this would get closed as off-topic on codeReview. Code on CR must be already working as intended before it can be reviewed. — Zak21 secs ago
I been having discussion with colleagues recently about good use of matchers. Consider the following sample:
@RunWith(MockitoJUnitRunner.class)
public class LoginRestServiceImplTest {
@Mock
private LoginService loginService;
@InjectMocks
private LoginRestService loginRestServi...
To review the code as it is:
It would be better not to even have result as a variable, and swap the order of operations inside the else-ifs that assign result from (result = X, gameResult++) to (gameResult++, return X)
You don't need semi-colons on the end of if statements:
} else {
retu...
Shall I make a curry function this way, or is it best to avoid Function constructor in all means ?
var curry = function(fn) {
var fnString = fn.toString();
var arity = fn.length;
var paramList = fnString.substring(
fnString.indexOf("(") + 1, fnString.indexOf(")")).split("...
Hey @DanPantry, on that answer I posted, I had to declare results separate to the function, I tried to declare it inside, but I couldn't figure out how. Is there a way to declare it inside, so that everytime I call RPSLZ() it'll keep the results?
@JeroenVannevel I'm not holding it against them being french. The OP made a comment that could be inferred to be rude depending on inflection. I was saying that because they are french (and not a native speaker), they may not be aware of the inflections/double handed compliment they made
@Vogel612 I was programming when I was 16; I programmed C++ in a predominately young-teenage-male community for WoW emulation. everyone was awful, including myself
I think it's not so much that 16y olds are bad coders. It's more that new coders are generally bad coders, and at 16, a much smaller proportion will not be new coders
I removed the comment anyway, but I didn't really find it rude. I saw it as a compliment, such as "Wow, you're only 16? You certainly know how to code".
i wouldn't worry about it. Questions like 'is this good' or 'did I write this code right?' is probably more suitable for another stack exchange website (codereview.stackexchange.com) — soulshined40 secs ago
In the pursuit of SQL enlightenment, I wrote a quick SEDE query to display Rep, Age and Overall Rank.
Sorted by Age, then Rank (Which is generated by Rep).
SELECT TOP 150
ROW_NUMBER() OVER (ORDER BY Users.Reputation DESC) AS Rank,
Users.Id as [User Link],
Users.Age,
Users.Reputation as R...
I got to show the createdAt date in a message timeline, I tried to make a separate array only for dates, but don't know if it is the right path to follow. It seems to me that my workaround is too tricky.
I'd like to be sure that what I've done is not THE RIGHT way, but at least it isn't A WRONG ...
Here is my Code
#region Native Methods and Constants
static class NativeMethods
{
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureNam...
I have this which is used to enable GC logging:
updateJVMArguments("-Xloggc:gc_" + myapp.getFileName() + "-" + getDateTime() +".log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M");
As you ca...
You have left commented code in. There's no reason to leave commented code in--we should let source control handle that. If we don't need it, eliminate it completely, because huge chunks of commented code are simply clutter that some maintainer will eventually delete anyway. And we shouldn't l...
I want to construct a string from several substrings, each one of those with a different delimiter. If the string is present, the delimiter and the string should be added, if not, none of them should be added.
This is my current code that looks a bit dirty to me:
def my_join(major, minor, pat...
@Morwenn I never got the appeal. Their cover the The Pretender is cool and I remember there was another song by them that the name escapes me now that I used to listen while playing WoW (oops)