We can use partial application to "lock" the first argument. After applying one argument we are left with a function which expects one more argument before returning the result.
(+) :: Int -> Int -> Int
addOne :: Int -> Int
addOne = (+) 1
We can then use addOne in order to...
Returning partially applied functions is one technique to write concise code.
add :: Int -> Int -> Int
add x = (+x)
add 5 2
In this example (+x) is a partially applied function. Notice that the second parameter to the add function does not need to be specified in the function definitio...
A type has value semantics if the object's observable state is functionally distinct from all other objects of that type. This means that if you copy an object, you have a new object, and modifications of the new object will not be in any way visible from the old object.
Most basic C++ types have v...
Sometimes two arrays of the same length need to be iterated together, for example:
$people = ['Tim', 'Tony', 'Turanga'];
$foods = ['chicken', 'beef', 'slurm'];
array_map is the simplest way to accomplish this:
array_map(function($person, $food) {
return "$person likes $food\n";
...
Model
using System.ComponentModel.DataAnnotations;
public class ViewModel
{
[Required(ErrorMessage="Name is required")]
public string Name { get; set; }
[StringLength(14, MinimumLength = 14, ErrorMessage = "Invalid Phone Number")]
[Required(ErrorMessag...
Remote Validation used to check whether the content enter in the input control is valid or not by sending an ajax request to server side to check it.
Working
The RemoteAttribute works by making an AJAX call from the client to a controller action with the value of the field being validated. The con...
PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database (since version 7), TimesTen in-memory database (since version 11.2.1), and IBM DB2 (since version 9.7).
The basic un...
Once the Symfony Installer is available, create your first Symfony application with the new command:
# Linux, Mac OS X
$ symfony new my_project_name
# Windows
c:\> cd projects/
c:\projects\> php symfony new my_project_name
This command can be run from anywhere, not necessarily from t...
In Kotlin you could write code like:
val x: Path = Paths.get("dirName").apply {
if (Files.notExists(this)) throw IllegalStateException("The important file does not exist")
}
But the use of apply is not that clear as to your intent. Sometimes it is clearer to create a ...
If you want to extend a class as-if you are a static function, for example for class Something add static looking function fromString, this can only work if the class has a companion object and that the extension function has been declared upon the companion object:
class Something {
compani...
Kotlin allows us to provide implementations for a predefined set of operators with fixed symbolic representation (like + or *) and fixed precedence. To implement an operator, we provide a member function or an extension function with a fixed name, for the corresponding type. Functions that overload ...
NumPy is available in the default repositories of most popular Linux distributions and can be installed in the same way that packages in a Linux distribution are usually installed.
Some Linux distributions have different NumPy packages for Python 2.x and Python 3.x. In Ubuntu and Debian, install nu...
Custom routing provides specialized need of routing to handle specific incoming requests.
In order to defining custom routes, keep in mind that the order of routes that you add to the route table is important.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute(&qu...
To get Unix Epoch Time, use the constant timeIntervalSince1970:
Swift
let date = NSDate() // current date
let unixtime = date.timeIntervalSince1970
Objective-C
NSDate *date = [NSDate date]; // current date
int unixtime = [date timeIntervalSince1970];
Uppercase and lowercase letters of the alphabet are equivalent in the
Fortran character set. In other words, Fortran is case insensitive. This behavior is in contrast with case-sensitive languages, such as C++ and many others.
As a consequence, the variables a and A are the same variable. In princ...
Sample Data:
CREATE TABLE table_name ( id, list ) AS
SELECT 1, 'a,b,c,d' FROM DUAL UNION ALL -- Multiple items in the list
SELECT 2, 'e' FROM DUAL UNION ALL -- Single item in the list
SELECT 3, NULL FROM DUAL UNION ALL -- NULL list
SELECT 4, 'f,,g' FROM DUAL; -- NULL item...