Tutorial by Examples

Program units often make use of literal constants. These cover the obvious cases like print *, "Hello", 1, 1.0 Except in one case, each literal constant is a scalar which has type, type parameters and value given by the syntax. Integer literal constants are of the form 1 -1 -1_1 ...
You can call a function in Racket by wrapping it in parentheses with the arguments after it. This looks like (function argument ...). > (define (f x) x) > (f 1) 1 > (f "salmon") "salmon" > (define (g x y) (string-append x y)) > (g "large" "sal...
A common pattern in C# is using bool TryParse(object input, out object value) to safely parse objects. The out var declaration is a simple feature to improve readability. It allows a variable to be declared at the same time that is it passed as an out parameter. A variable declared this way is sco...
The 0b prefix can be used to represent Binary literals. Binary literals allow constructing numbers from zeroes and ones, which makes seeing which bits are set in the binary representation of a number much easier. This can be useful for working with binary flags. The following are equivalent ways o...
The underscore _ may be used as a digit separator. Being able to group digits in large numeric literals has a significant impact on readability. The underscore may occur anywhere in a numeric literal except as noted below. Different groupings may make sense in different scenarios or with different ...
Basics A tuple is an ordered, finite list of elements. Tuples are commonly used in programming as a means to work with one single entity collectively instead of individually working with each of the tuple's elements, and to represent individual rows (ie. "records") in a relational databa...
Local functions are defined within a method and aren't available outside of it. They have access to all local variables and support iterators, async/await and lambda syntax. This way, repetitions specific to a function can be functionalized without crowding the class. As a side effect, this improves...
Define AccumulatorParam import org.apache.spark.AccumulatorParam object StringAccumulator extends AccumulatorParam[String] { def zero(s: String): String = s def addInPlace(s1: String, s2: String)= s1 + s2 } Use: val accumulator = sc.accumulator("")(StringAccumulator) sc.pa...
Define AccumulatorParam: from pyspark import AccumulatorParam class StringAccumulator(AccumulatorParam): def zero(self, s): return s def addInPlace(self, s1, s2): return s1 + s2 accumulator = sc.accumulator("", StringAccumulator()) def add(x): gl...
Preconditions allows methods to provide minimum required values for input parameters Example... void DoWork(string input) { Contract.Requires(!string.IsNullOrEmpty(input)); //do work } Static Analysis Result...
Postconditions ensure that the returned results from a method will match the provided definition. This provides the caller with a definition of the expected result. Postconditions may allowed for simplied implmentations as some possible outcomes can be provided by the static analyizer. Example......
AlertDialog.Builder builder = new AlertDialog.Builder(context); //Set Title builder.setTitle("Reset...") //Set Message .setMessage("Are you sure?") //Set the icon of the dialog .setIcon(drawable) //Set...
Let there be Activity B that can be opened, and can further start more Activities. But, user should not encounter it when navigating back in task activities. The simplest solution is to set the attribute noHistory to true for that <activity> tag in AndroidManifest.xml: <activity a...
Imagine you have the following HTML: <div> <label>Name:</label> John Smith </div> And you need to locate the text "John Smith" after the label element. In this case, you can locate the label element by text and then use .next_sibling property: from ...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element. Basic example: from bs4 import BeautifulSoup data = """ <ul> <li class="item&quo...
When the destructor for std::thread is invoked, a call to either join() or detach() must have been made. If a thread has not been joined or detached, then by default std::terminate will be called. Using RAII, this is generally simple enough to accomplish: class thread_joiner { public: thre...
Leading Zeros let number: Int = 7 let str1 = String(format: "%03d", number) // 007 let str2 = String(format: "%05d", number) // 00007 Numbers after Decimal let number: Float = 3.14159 let str1 = String(format: "%.2f", number) // 3.14 let str2 = String(format: &...
This example was done in order to demonstrate how you can perform a deep filter in a child array without the necessity of a custom filter. Controller: (function() { "use strict"; angular .module('app', []) .controller('mainCtrl', mainCtrl); function mainCtrl() { ...
Download a distributed archive from Binaries section of JMeter from Download Apache JMeter page. Depending on the version you downloaded, check minimal Java version requirements and install Java if needed. Ensure the JAVA_HOME environment variable is set and points to a correct version. ...
Installing Wildfly is just a matter of unzipping the distribution into your local machine. Wildfly can be dowloaded from its official website. Once it is unzipped go in to bin directory of installation and run standalone.sh for Linux systems or standalone.bat for Windows systems to start your WildF...

Page 238 of 1336