Tutorial by Examples: c

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...
Consider the character class [aeiou]. This character class can be used in a regular expression to match a set of similarly spelled words. b[aeiou]t matches: bat bet bit bot but It does not match: bout btt bt Character classes on their own match one and only one character at a time...
For Addition "4" + 2 # Gives "42" 4 + "2" # Gives 6 1,2,3 + "Hello" # Gives 1,2,3,"Hello" "Hello" + 1,2,3 # Gives "Hello1 2 3" For Multiplication "3" * 2 # Gives "33" 2 * "3&quot...
If a type wishes to have value semantics, and it needs to store objects that are dynamically allocated, then on copy operations, the type will need to allocate new copies of those objects. It must also do this for copy assignment. This kind of copying is called a "deep copy". It effective...
Swift let viewController = UIViewController() Objective-C UIViewController *viewController = [UIViewController new];
To access pixel values in an OpenCV cv::Mat object, you first have to know the type of your matrix. The most common types are: CV_8UC1 for 8-bit 1-channel grayscale images; CV_32FC1 for 32-bit floating point 1-channel grayscale images; CV_8UC3 for 8-bit 3-channel color images; and CV_32FC3 ...
Setup monitoring beacons func initiateRegion(ref:BeaconHandler){ let uuid: NSUUID = NSUUID(UUIDString: "<UUID>") let beacon = CLBeaconRegion(proximityUUID: uuid, identifier: "") locationManager?.requestAlwaysAuthorization() //cllocation manager obj. ...
beacon = CLBeaconRegion(proximityUUID: <#NSUUID#>, major: <#CLBeaconMajorValue#>, identifier: <#String#>) // listening to all beacons with given UUID and major value beacon = CLBeaconRegion(proximityUUID: <##NSUUID#>, major: <##CLBeaconMajorValue#>, minor: <##C...
Use to push commits made on your local branch to a remote repository. The git push command takes two arguments: A remote name, for example, origin A branch name, for example, master For example: git push <REMOTENAME> <BRANCHNAME> As an example, you usually run git push orig...
Swift class FooViewController: UIViewController { override func loadView() { view = FooView() } }
Spacemacs is a popular starter kit for emacs. It features a robust package management solution and centers around emacs's popular evil mode, which provides many of the keybindings from vim. It is called Spacemacs because it uses the Space key as the leader key (the idea is similar to Vim's leader k...
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...
To install packages directly from GitHub use the devtools package: library(devtools) install_github("authorName/repositoryName") To install ggplot2 from github: devtools::install_github("tidyverse/ggplot2") The above command will install the version of ggplot2 that corre...
We have to create a view which will have a image prefix to a text. text could be of variable length.We have to achieve a result where in Image + text is always in center of a parent view. Step 1: First create a single view project and name it something of your choice and open the story board fist...
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 case your project needs to be based on a specific Symfony version, use the optional second argument of the new command: # use the most recent version in any Symfony branch $ symfony new my_project_name 2.8 $ symfony new my_project_name 3.1 # use a specific Symfony version $ symfony new my_...
Open your command console and execute the following commands: $ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony $ sudo chmod a+x /usr/local/bin/symfony
A common use case for extension methods is to improve an existing API. Here are examples of adding exist, notExists and deleteRecursively to the Java 7+ Path class: fun Path.exists(): Boolean = Files.exists(this) fun Path.notExists(): Boolean = !this.exists() fun Path.deleteRecursively(): Bool...
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 ...

Page 149 of 826