Create a function with optional call variables

Powershell provides a lot of built-in support for common parameter scenarios, including mandatory parameters, optional parameters, “switch” (aka flag) parameters, and “parameter sets.” By default, all parameters are optional. The most basic approach is to simply check each one for $null, then implement whatever logic you want from there. This is basically what you have … Read more

Function overloading in PowerShell

In PowerShell functions are not overloaded. The last definition overrides the previous in the same scope or hides the previous in a parent scope. Thus, you should create a single function and provide a way to distinguish its call mode by arguments. In V2 you may use an advanced function, see help about_Functions_Advanced_Parameters and avoid … Read more

Why is Function[-A1,…,+B] not about allowing any supertypes as parameters?

Covariance and contravariance are qualities of the class not qualities of the parameters. (They are qualities that depend on the parameters, but they make statements about the class.) So, Function1[-A,+B] means that a function that takes superclasses of A can be viewed as a subclass of the original function. Let’s see this in practice: class … Read more

No function matches the given name and argument types

Your function has a couple of smallint parameters. But in the call, you are using numeric literals that are presumed to be type integer. A string literal or string constant (‘123’) is not typed immediately. It remains type “unknown” until assigned or cast explicitly. However, a numeric literal or numeric constant is typed immediately. The … Read more

nth percentile calculations in postgresql

With PostgreSQL 9.4 there is native support for percentiles now, implemented in Ordered-Set Aggregate Functions: percentile_cont(fraction) WITHIN GROUP (ORDER BY sort_expression) continuous percentile: returns a value corresponding to the specified fraction in the ordering, interpolating between adjacent input items if needed percentile_cont(fractions) WITHIN GROUP (ORDER BY sort_expression) multiple continuous percentile: returns an array of results … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)