Keep multiple parameters on one line in scalafmt - scalafmt

I want Scalafmt to accept this kind of formatting:
val result = longMethodName(
a, b, c, d)
But currently it gets turned into:
val result = longMethodName(
a,
b,
c,
d)
When the parameters are short the first form is much more pleasing. Is there an option to allow it?

Related

xlrd dynamic variables python

I can make it work like this:
book = xlrd.open_workbook(Path+'infile')
sheet = book.sheet_by_index(0)
A, B, C, D = ([] for i in range (4))
A = sheet.col_values(0)
B = sheet.col_values(1)
C = sheet.col_values(2)
D = sheet.col_values(3)
but what I want is to make it work like this:
dyn_var_list = [A, B, C, D]
assert(len(sheet.row_values(0))==len(dyn_var_list))
for index, col in enumerate(sheet.row_values(0)):
dyn_var_list[index].append(col)
however, so far I can only get one value in my lists, using the code above, which is due to the usage of "(0)" after the row_values I guess, but I don't know how to resolve this as of yet.
Try
for c in range(sheet.ncols):
for r in range(sheet.nrows):
dyn_var_list[c].append(sheet.cell(r,c).value)
Here sheet.nrows gives you the number of rows in the sheet.

Arrange numbers in order

I've some variables, Lets say a, b, c, d. All belongs to a fixed interval [0, e]
Now i've some relations between them like
a > b
a > c
b > d
Something like this; I want to make a function which print all the possible cases for this.
Example:
a b c d
a c b d
a b d c
a c b d
In essence, what you have is a directed acyclic graph.
A relatively simple approach is to store, for each variable, a set of the variables that must precede them. (In your example, this storage would map b to {a}, c to {a}, and d to {b}.) You can then write a recursive function that generates all valid tails consisting of a subset of these variables (in your case, for example, the subset {c,d} produces two valid tails: [c,d] and [d,c]). This recursive function examines each variable in the subset and determines whether its prerequisites are already met. (For example, since b maps to {a}, any subset including both a and b cannot produce a tail that begins with b.) If so, then it can recursively call itself on the subset excluding that variable.
There are some optimizations you can then perform, if desired. For example, you can use dynamic programming to avoid repeatedly re-computing the set of valid tails for the same subset.

What makes Crystal (or SQL Server 2012) shorten strings from a database and how to prevent it?

What might cause the following and how can I prevent it?
A command object in the Crystal 2011 “database expert” was something like
Select A, B, C, D, E, F, G, H, I, J from ……
As I was fiddling with format and parameters, Crystal started chopping off A after seventeen characters. The truncation was visible early on, in the “browse data” function of field explorer.
After about a half-hour of trying to figure out why, I gave up and added a needed data item:
Select A, B, C, D, E, F, XXX, G, H, I, J from ……
A went back to normal but B started getting truncated.
So I added a fake item at the end
Select A, B, C, D, E, F, X, G, H, I, J, 'Nil' as Nil from ……
and B went back to normal !

What is impossible?

Hi recently i appeared in an aptitude,there was a problem that i realy cant understand please provide some idea, how to solve it.(and sorry to for poor English.)
(Question)-> Three candidates, Amar, Birendra and Chanchal stand for the local election. Opinion polls are
conducted and show that fraction a of the voters prefer Amar to Birendra, fraction b prefer Birendra to
Chanchal and fraction c prefer Chanchal to Amar. Which of the following is impossible?
(a) (a, b, c) = (0.51, 0.51, 0.51);
(b) (a, b, c) = (0.61, 0.71, 0.67);
(c) (a, b, c) = (0.68, 0.68, 0.68);
(d) (a, b, c) = (0.49, 0.49, 0.49);
(e) None of the above.
If you tried to list of possible preferences people can have
are either
ABC (means you prefer A to B, prefer B to C and therefore also prefer A to C)
ACB
BAC
BCA
CAB
CBA
in this case you'll find that each fraction of the population represents:
a=ABC+ACB+CAB
b=ABC+BAC+BCA
c=BCA+CAB+CBA
therefore a+b+c = 2(ABC+BCA+CAB)+ACB+BAC+CBA
as you notice not all groups within the population are repeated. we can therefore assume than (a+b+c) can never be more than twice the population since each member of the population is represented twice at the most.
out of the options C is the one where the sum is more than 2. and is therefore the impossible value.

Which languages have a primitive operation for swapping variables?

In most languages, if you want to swap two variables, it's something like:
var c = b
b = a
a = c
Yes, you can do fancy hacks with XOR if you like but it's generally 3 lines of code for a single operation. Are there any languages that have swapping variables as a primitive in the language?
Lua, Python, Ruby and more support this notation:
a, b = b, a
And javascript sure needs no temporary variable either ;)
a = -(b = (a += b) - b) + a;
For more examples on how to swap variables (in 86 languages), see: http://rosettacode.org/wiki/Generic_swap
In most dynamic languages you can do something like this to swap:
a, b = b, a
Now a have the value of b, and b has the value of a. I am not sure if this is what you meant or not.