Tutorial by Examples: ae

List<int> l2 = l1.FindAll(x => x > 6); Here x => x > 6 is a lambda expression acting as a predicate that makes sure that only elements above 6 are returned.
public delegate int ModifyInt(int input); ModifyInt multiplyByTwo = x => x * 2; The above Lambda expression syntax is equivalent to the following verbose code: public delegate int ModifyInt(int input); ModifyInt multiplyByTwo = delegate(int x){ return x * 2; };
Use parentheses around the expression to the left of the => operator to indicate multiple parameters. delegate int ModifyInt(int input1, int input2); ModifyInt multiplyTwoInts = (x,y) => x * y; Similarly, an empty set of parentheses indicates that the function does not accept parameters. ...
Sorting lists Prior to Java 8, it was necessary to implement the java.util.Comparator interface with an anonymous (or named) class when sorting a list1: Java SE 1.2 List<Person> people = ... Collections.sort( people, new Comparator<Person>() { public int compare(Pe...
First example reimplemented in Kotlin and using RxJava for cleaner interaction. import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.support.v7.widget.RecyclerView import rx.subjects.PublishSubject public class SampleAdapter(private val ite...
A lambda expression provides a concise way to create simple function objects. A lambda expression is a prvalue whose result object is called closure object, which behaves like a function object. The name 'lambda expression' originates from lambda calculus, which is a mathematical formalism invented...
All Java exceptions are instances of classes in the Exception class hierarchy. This can be represented as follows: java.lang.Throwable - This is the base class for all exception classes. Its methods and constructors implement a range of functionality common to all exceptions. java.lang.Excep...
SFINAE stands for Substitution Failure Is Not An Error. Ill-formed code that results from substituting types (or values) to instantiate a function template or a class template is not a hard compile error, it is only treated as a deduction failure. Deduction failures on instantiating function templa...
There are two ways to achieve that, the first and most known is the following: docker attach --sig-proxy=false <container> This one literally attaches your bash to the container bash, meaning that if you have a running script, you will see the result. To detach, just type: Ctl-P Ctl-Q Bu...
Lambda expressions can be used to handle events, which is useful when: The handler is short. The handler never needs to be unsubscribed. A good situation in which a lambda event handler might be used is given below: smtpClient.SendCompleted += (sender, args) => Console.WriteLine("Ema...
Java-like enumerations can be created by extending Enumeration. object WeekDays extends Enumeration { val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value } def isWeekend(day: WeekDays.Value): Boolean = day match { case WeekDays.Sat | WeekDays.Sun => true case _ => false } isWeekend...
// A simple adder function defined as a lambda expression. // Unlike with regular functions, parameter types often may be omitted because the // compiler can infer their types let adder = |a, b| a + b; // Lambdas can span across multiple lines, like normal functions. let multiplier = |a: i32, ...
C++11 // Include sequence containers #include <vector> #include <deque> #include <list> #include <array> #include <forward_list> // Include sorting algorithm #include <algorithm> class Base { public: // Constructor that set variable to the va...
Elm has a special syntax for lambda expressions or anonymous functions: \arguments -> returnedValue For example, as seen in List.filter: > List.filter (\num -> num > 1) [1,2,3] [2,3] : List number More to the depth, a backward slash, \, is used to mark the beginning of lambda ex...
The following example encrypts data by using a hybrid cryptosystem consisting of AES GCM and OAEP, using their default parameter sizes and an AES key size of 128 bits. OAEP is less vulnerable to padding oracle attacks than PKCS#1 v1.5 padding. GCM is also protected against padding oracle attacks. ...
Following is most basic expression tree that is created by lambda. Expression<Func<int, bool>> lambda = num => num == 42; To create expression trees 'by hand', one should use Expression class. Expression above would be equivalent to: ParameterExpression parameter = Expression.Pa...
TeX formulae can be inserted in the plot using the rc function import matplotlib.pyplot as plt plt.rc(usetex = True) or accessing the rcParams: import matplotlib.pyplot as plt params = {'tex.usetex': True} plt.rcParams.update(params) TeX uses the backslash \ for commands and symbols, whic...
import os, sys from openpyxl import Workbook from datetime import datetime dt = datetime.now() list_values = [["01/01/2016", "05:00:00", 3], \ ["01/02/2016", "06:00:00", 4], \ ["01/03/2016", "07:00:00",...
SOAP services can publish metadata that describes the methods that may be invoked by clients. Clients can use tools such as Visual Studio to automatically generate code (known as client proxies). The proxies hide the complexity of invoking a service. To invoke a service, one merely invokes a metho...
Introduction As memory prices dropped, Intel-based PCs were able to have more and more RAM affordably, alleviating many users' problems with running many of the ever-larger applications that were being produced simultaneously. While virtual memory allowed memory to be virtually "created" ...

Page 1 of 5