What's the deal with Deno? We talk with a major contributor to find out. Listen now.

# Tag Info

10

Physics is wrong. The Brownian motion is isotropic. Your model is not. The steps in major directions are xIncrement and yIncrement ($I_x$ and $I_y$ respectively), but the steps along the diagonals are larger, $\sqrt{I_x^2 + I_y^2}$. The tests hide it because of the random initial positions. Shall you follow instructions and set the particles at the ...

8

Spread Similar to Mohammed's answer, but without mutation and with spread syntax, which I find easier to read than .apply, you can do something like: const executeModeration = async (command, channel) => { await moderation[command.command](...command.parameters); } Default parameters You use a number of conditional operators when calling functions, ...

7

Overall Observations The more code you provide the better the reviews you will get. There are 2 statements, 1 in the question and 1 in the comments after the question that almost make it off-topic for the Code Review site: ... my real code does not print for each iteration, this is for easy testing. I have another function that calculates that "free ...

7

Naming The names are not wrong, but I find them very verbose, which makes the code longer and harder to read and write. private double xPosition; private double yPosition; private final double particleRadius; It would be fine with x y and radius , and I see no risk of confusion as to the meaning of those names. This spreads further through your code when ...

7

My answers will comport several steps. Some steps won't be present anymore in the final answer, but I mention them because you might find interesting to follow that in other contexts. Multiple usage of the same reference to command.parameters[0], command.parameters[1], ... You are using command.parameters[0] literally everywhere. If what you're writing look ...

7

Overview I think the most telling part is this: int decimal; That's probably not a decimal number. In most modern computer this is stored as a binary number (though in some exceedingly old computers they did use decimals but they gave up on decimal computers in favor of binary very quickly). The problem with your code is that a number is a number. ...

7

I'm not a JavaScipt programmer, so my suggestions are limited Is there any obvious beginner flaws? Using a large case statement like this is a beginners flaw, because it is difficult to maintain (expansion and contraction are difficult) and performance could be improved. In C++ I would use a map of keywords to functions and I would do something similar in ...

7

You can use Function.prototype.apply(), your code can be like below:- const executeModeration = async (command, channel) => { command.parameters.unshift(channel); await moderation[command.command].apply(null, command.parameters); } you can handle ternary operators logic inside corresponding method.

5

First of all, a general rule is that if you have more than a few else-ifs, you should start looking for a different control structure. For instance, you could replace your if-then-else-if block with xPosition += (round(3*random)%3-1)*xIncrement; yPosition += (round(9*random)%3-1)*yIncrement; But it's probably better to have two separate random numbers for x ...

5

Use extend() instead of append() to add a list to another list, and use the fact that None and empty lists compare as False, while a non-empty list compares as True, and omit the redundant return statement: def test(x1, x2): if x2: x1.extend(x2) As for reducing the number of print statements, prepare a list or tuple with your test cases, and ...

5

Like Mohammed suggested, Function.apply() could be used to replace the switch statement. Variable naming If the first argument ‘command‘ is an object that contains a string at key ‘command‘ then a better name would be in line for readability- e.g. ‘options‘. Argument use Because Ecmascript-2015 (A.K.A. ES-6) features like arrow functions are used (as well as ...

5

As pointed out by @iSR5's comment, A DataSet is basically a wrapper around a collection or DataTable objects. It has some other helpful utility methods, but from a performance point of view the only performance issue with your logic is that in the DataSet solution you need to access the table to read from through the indexer that has assumed that there is a ...

4

I have some suggestions for your code. Extract the expression to variables when used multiple times. You have multiple instances where you use the method getCoordinatesLength / getCoordinate multiple times in the same method. In your code, you can extract the similar expressions into variables; this will make the code shorter and easier to read. Simplify ...

3

Summary: You need to decide whether you are doing a random walk on a lattice (with int) or a random walk on a continuum (with double). I'm going to discuss the physics and scientific computing aspects. Brownian motion on a square lattice Contrary to what was said in another answer, the physics is not necessarily wrong. First, you might be simulating ...

3

Knowing that Vector is already a common class in Java, choosing Vector as a name for another class becomes quite confusing. Since this is specifically an Euclidean vector, you should literally name the class as such: EuclideanVector. The class is intended to be immutable but it's constructor exposes the internal data structure to external components and ...

2

We should remove the file information from the loops. We should interact with the files and the output outside the loop. Note: Code changed to follow a standard Python style def generate_numbers(update, length): chunks = 1 while True: for u in range(1, 501): for g in range(1, 500): if chunks * (g + (u - 1) * 500) &...

2

This solution may not be appropriate for your project depending on how else commands are used in your codebase, or if the commands are provided by an external library, among other things. But based on the snippet you give here, it might be a more suitable way to structure your code. Let's start by reviewing two key elements of your code here: commands and ...

2

Let's try the other way: function loadPath(path, chunkSize, dataSize, depth, index) { for(var i = 0; i < depth; i++) { path[depth - i - 1] = index % chunkSize; index = Math.floor(index / chunkSize); }; }; var path = Array(3); console.log("loadPath(path, 5, 100, 3, 41)"); loadPath(path, 5, 100, 3, 41); console.log(path); console.log("...

2

I think it can be something like this, also it can be improved by using variable names that reflects your business conditions better. private void UpdateAccount(UserModel userData) { Account accountById = _accountController.GetAccountById(userData.Id); Account accountByNumber = _accountController.GetAccountByNumber(userData.Number); ...

1

Here is my code review. It is a good practice to add type hints to Python functions to specify parameter types. See here for more details. Note that type hints do not affect code execution. It is primarily for improving readability and helping IDEs look for potential bugs. When running code outside a function / class, it is a good practice to put the code ...

Only top voted, non community-wiki answers of a minimum length are eligible