here you can find the functions.
With the table wf_example created in previous example, run:
select i
, dense_rank() over (order by i)
, row_number() over ()
, rank() over (order by i)
from wf_example
The result is:
i | dense_rank | row_number | rank
---+------------+------------+-...
Typescript supports costant enumerables, declared through const enum.
This is usually just syntax sugar as the costant enums are inlined in compiled JavaScript.
For instance the following code
const enum Tristate {
True,
False,
Unknown
}
var something = Tristate.True;
compil...
If a feature is largely lacking data, it is a good candidate for removal:
library(VIM)
data(sleep)
colMeans(is.na(sleep))
BodyWgt BrainWgt NonD Dream Sleep Span Gest
0.00000000 0.00000000 0.22580645 0.19354839 0.06451613 0.06451613 0.06451613
Pred ...
By default all enum values are resolved to numbers. Let's say if you have something like
enum MimeType {
JPEG,
PNG,
PDF
}
the real value behind e.g. MimeType.PDF will be 2.
But some of the time it is important to have the enum resolve to a different type. E.g. you receive the value fr...
Numeric operators are the easiest and almost the same as in other languages.
+, -, * and /. Addition, subtraction, multiplication and division operators (in VFP there is no integer division, you can convert a result to integer with functions INT(), CEILING() and FLOOR()).
% Modulus operator.
^ ...
In order to get the total number of commits that each developer or contributor has made on a repository, you can simply use the git shortlog:
git shortlog -s
which provides the author names and number of commits by each one.
Additionally, if you want to have the results calculated on all branch...
Visual Basic.NET, like most languages, permits recursion, a process by which a function calls itself under certain conditions.
Here is a basic function in Visual Basic .NET to compute Fibonacci numbers.
''' <summary>
''' Gets the n'th Fibonacci number
''' </summary>
''' <param na...
If an integer x is a power of 2, only one bit is set, whereas x-1 has all bits set after that. For example: 4 is 100 and 3 is 011 as binary number, which satisfies the aforementioned condition. Zero is not a power of 2 and has to be checked explicitly.
boolean isPowerOfTwo(int x)
{
return (x ...
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df
Out[2]:
A B C D
0 1 1.0 a True
1 2 2.0 b False
2 3 3.0 c True
Getting a python list from a series:
In [3]: df['...
Given coins of different denominations and a total, in how many ways can we combine these coins to get the total? Let's say we have coins = {1, 2, 3} and a total = 5, we can get the total in 5 ways:
1 1 1 1 1
1 1 1 2
1 1 3
1 2 2
2 3
The problem is closely related to knapsack problem. The o...
Given coins of different denominations and a total, how many coins do we need to combine to get the total if we use minimum number of coins? Let's say we have coins = {1, 5, 6, 8} and a total = 11, we can get the total using 2 coins which is {5, 6}. This is indeed the minimum number of coins require...
//integer (not really needed unless you need to round numbers, Excel with use default cell properties)
worksheet.Cells["A1:A25"].Style.Numberformat.Format = "0";
//integer without displaying the number 0 in the cell
worksheet.Cells["A1:A25"].Style.Numberformat.Form...
Consider the ranges A1:A3 and B1:B3 having the same size and only number values, as below
=SUMPRODUCT(A1:A3,B1:B3)
This will loop through the ranges, taking the product of values in the same row and summing them, returning 32 in this example.
A1*B1 = 4
A2*B2 = 10
A3*B3 = 18
Print a number in binary, quaternary, octal, hexadecimal and a general power of two
All the bases that are a power of two, like the binary (21), quaternary (22), octal (23), hexadecimal (24) bases, have an integral number of bits per digit1.
Thus to retrieve each digit2 of a numeral we simply brea...
Print a 16-bit unsigned number in decimal
The interrupt service Int 21/AH=02h is used to print the digits.
The standard conversion from number to numeral is performed with the div instruction, the dividend is initially the highest power of ten fitting 16 bits (104) and it is reduced to lower power...
A enum declares a set of ordered values - the typedef just adds a handy name to this. The 1st element is 0 etc.
typedef enum {
Monday=1,
Tuesday,
Wednesday
} WORKDAYS;
WORKDAYS today = Monday;//value 1
In the file myConfig.groovy is the following content.
message = 'Hello World!'
aNumber=42
aBoolean=false
aList=["apples", "grapes", "oranges"]
Then in your main script you create a ConfigSlurper for your myConfig.groovy file which is really just another groovy sc...
The following example shows other ways you can use the underscore in numeric literals:
long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
float pi = 3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;...
If the engine is able to correctly predict you're using a specific small type for your values, it will be able to optimize the executed code.
In this example, we'll use this trivial function summing the elements of an array and outputting the time it took:
// summing properties
var sum = (functio...