Tutorial by Examples: is

> listOfNumbers = [1,4,99] [1,4,99] : List number > > listOfStrings = ["Hello","World"] ["Hello","World"] : List String > > emptyList = [] -- can be anything, we don't know yet [] : List a > Under the hood, List (linked list) is ...
List.map : (a -> b) -> List a -> List b is a higher-order function that applies a one-parameter function to each element of a list, returning a new list with the modified values. import String ourList : List String ourList = ["wubba", "lubba", "dub",...
List.filter : (a -> Bool) -> List a -> List a is a higher-order function which takes a one-parameter function from any value to a boolean, and applies that function to every element of a given list, keeping only those elements for which the function returns True on. The function that List.f...
To create a collection of n copies of some object x, use the fill method. This example creates a List, but this can work with other collections for which fill makes sense: // List.fill(n)(x) scala > List.fill(3)("Hello World") res0: List[String] = List(Hello World, Hello World, Hello...
Grand Central Dispatch works on the concept of "Dispatch Queues". A dispatch queue executes tasks you designate in the order which they are passed. There are three types of dispatch queues: Serial Dispatch Queues (aka private dispatch queues) execute one task at a time, in order. They a...
3.0 To run tasks on a dispatch queue, use the sync, async, and after methods. To dispatch a task to a queue asynchronously: let queue = DispatchQueue(label: "myQueueName") queue.async { //do something DispatchQueue.main.async { //this will be called in main t...
Display multiple plots in one image with the different facet functions. An advantage of this method is that all axes share the same scale across charts, making it easy to compare them at a glance. We'll use the mpg dataset included in ggplot2. Wrap charts line by line (attempts to create a square l...
Lists allow users to store multiple elements (like vectors and matrices) under a single object. You can use the list function to create a list: l1 <- list(c(1, 2, 3), c("a", "b", "c")) l1 ## [[1]] ## [1] 1 2 3 ## ## [[2]] ## [1] "a" "b" &q...
Sometimes, we need to update the progress of the computation done by an AsyncTask. This progress could be represented by a string, an integer, etc. To do this, we have to use two functions. First, we need to set the onProgressUpdate function whose parameter type is the same as the second type parame...
When filtering a value that should be an integer filter_var() will return the filtered data, in this case the integer, or false if the value is not an integer. Floats are not integers: var_dump(filter_var('10', FILTER_VALIDATE_INT)); var_dump(filter_var('a10', FILTER_VALIDATE_INT)); var_dump(filt...
You can nest lists to represent sub-items of a list item. <ul> <li>item 1</li> <li>item 2 <ul> <li>sub-item 2.1</li> <li>sub-item 2.2</li> </ul> </li> <li>item 3</li> </ul> ...
A list can be subset with [: l1 <- list(c(1, 2, 3), 'two' = c("a", "b", "c"), list(10, 20)) l1 ## [[1]] ## [1] 1 2 3 ## ## $two ## [1] "a" "b" "c" ## ## [[3]] ## [[3]][[1]] ## [1] 10 ## ## [[3]][[2]] ## [1] 20 l1[1] ##...
Simple check To check if constant is defined use the defined function. Note that this function doesn't care about constant's value, it only cares if the constant exists or not. Even if the value of the constant is null or false the function will still return true. <?php define("GOOD&quo...
To assert that a value is either true or false,: Assert.IsFalse(Settings.DoBadThings, "Bad things should not happen, disable DoBadThings."); Assert.IsTrue(magicNumber =< 42, "The magic number is greater than 42!"); You can also pass formatting parameters for the exception...
Checks to see if the passed Item is in Editing mode. If not, it throws an EditingNotAllowedException. Assert.IsEditing(Sitecore.Context.Item);
This query returns all cones with either a mint scoop or a vanilla scoop. minty_vanilla_cones = IceCream.objects.filter(scoops__contained_by=[MINT, VANILLA])
Twilio's Node.JS API natively supports promises, allowing you to use promises when sending SMS messages (this example was taken and adapted directly from Twilio's API Docs). // Create an authenticated Twilio REST API client var twilio = require('twilio'); var client = new twilio.RestClient('ACCOU...
The FlagsAttribute should be used whenever the enumerable represents a collection of flags, rather than a single value. The numeric value assigned to each enum value helps when manipulating enums using bitwise operators. Example 1 : With [Flags] [Flags] enum Colors { Red=1, Blue=2, ...
php artisan route:list --method=GET --method=POST This will include all routes that accept GET and POST methods simultaneously.
<!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <title></title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <!-- find the latest library and style versions here: https://www.mapbox.com/m...

Page 16 of 109