Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in the original collection and inserts each return value into the new collection. It returns the new collection.
This is a simple map that takes a list of names and returns a list of the...
Reduce takes a function and a collection of items. It returns a value that is created by combining the items.
This is a simple reduce. It returns the sum of all the items in the collection.
total = reduce(lambda a, x: a + x, [0, 1, 2, 3, 4])
print(total) =>10
Filter takes a function and a collection. It returns a collection of every item for which the function returned True.
arr=[1,2,3,4,5,6]
[i for i in filter(lambda x:x>4,arr)] # outputs[5,6]
//Header File
<CallKit/CXCallObserver.h>
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
// If queue is nil, then callbacks will be performed on main queue
[callObserver setDelegate:self queue:nil];
// Don't forget to store reference to callObserver, to prevent it ...
Processing Field collection items with Rules is fun, really! Have a look at this Rule (in Rules export format):
{ "rules_calculate_sum_of_prices_in_all_field_collection_items" : {
"LABEL" : "Calculate sum of prices in all field collection items",
"PLUGIN...
It's possible to pass variables from your server into Pug for dynamic content or script generation. Pug templates can access variables passed to the res.render function in Express (or pug.renderFile if you are not using Express, the arguments are identical).
index.js
let colors = ["Red",...
Content interpolated with bracket syntax will be evaluated for code, the output of which is included in your HTML output.
title follows the basic pattern for evaluating a template local, but the code in between #{and } is evaluated, escaped, and the result buffered into the output of the template...
Interpolating values is helpful if you need to pass a server-side variable to client-side JavaScript (or other languages that require it).
In the case of variables, numbers, strings, and the like, you can pass these types of variables directly into your JavaScript with bracket syntax plus an explan...
It may be necessary to nest HTML tags inside of each other. Element interpolation is done in a syntax similar to variable interpolation; square brackets instead of curly braces are used here. The syntax of interpolated HTML elements is identical to the implementation of normal HTML elements.
index....
Let's see how we can organize the code, when the codebase is getting larger.
01. Functions
fn main() {
greet();
}
fn greet() {
println!("Hello, world!");
}
02. Modules - In the same file
fn main() {
greet::hello();
}
mod greet {
// By default, everything inside a...
In Strict Mode, functions declared in a local block are inaccessible outside the block.
"use strict";
{
f(); // 'hi'
function f() {console.log('hi');}
}
f(); // ReferenceError: f is not defined
Scope-wise, function declarations in Strict Mode have the same kind of binding as l...
In this example I will be using oauth2 in rest api with redis database
Important: You will need to install redis database on your machine,
Download it from here for linux users and from here to install
windows version, and we will be using redis manager desktop app,
install it from here.
...
Use case: just one action which should return a plain (text) content as-is:
public function actionAsXML()
{
$this->layout = false;
Yii::$app->response->format = Response::FORMAT_XML;
return ['aaa' => [1, 2, 3, 4]];;
}
Pre-defined response formats are:
FORMAT_HTM...
In the following we will install Plesk Onyx on Windows Server (2016) using the Plesk Installer GUI.
Preparations
For installing Plesk we need a running Windows Server (2012/2016) installation. The Hardware recommendation is a minimum of 2GB RAM and 30GB free disk space. Have a look at the official...
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)
For Each objItem in colItems
WScript.Echo "ScreenHeight: " &am...
The sample command can be used to simulate classic probability problems like drawing from an urn with and without replacement, or creating random permutations.
Note that throughout this example, set.seed is used to ensure that the example code is reproducible. However, sample will work without expl...
One of the most critical parts of dealing with NMS code is being able to support mulitple Minecraft versions. There are numerous ways to do this, but a simple solution is to use this code to store the version as a public static field:
public static final String NMS_VERSION = Bukkit.getServer().getC...
This example shows how to obtain the ancestry of a component using the ClassType and ClassParent properties. It uses a button Button1: TButton and a list box ListBox1: TListBox on a form TForm1.
When the user clicks the button, the name of the button’s class and the names of its parent classes are ...