Tutorial by Examples: f

import java.util.Scanner; Scanner s = new Scanner(System.in); int number = s.nextInt(); If you want to read an int from the command line, just use this snippet. First of all, you have to create a Scanner object, that listens to System.in, which is by default the Command Line, when you start ...
SpriteKit functionality can be implemented in a subclass of SKScene. For example, a game may implement the main game functionality within an SKScene subclass called GameScene. In Swift: import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Co...
A simple use case it to create an SKScene that exactly fills the SKView. This avoids the need to consider scaling the view to fit or setting a camera to show a part of the scene. The following code assumes an SKView called skView already exists (e.g. as defined in Create a Full Screen SKView using ...
An SKScene has a scaleMode parameter that defines how it will change its size to fit within the SKView it is presented into the SKView if it is not the same size and/or shape. There are four options for scaleMode: AspectFit: the scene is scaled (but not stretched) until it fits within the view. ...
class SomeClass { public function __invoke($param1, $param2) { // put your code here } } $instance = new SomeClass(); $instance('First', 'Second'); // call the __invoke() method An object with an __invoke method can be used exactly as any other function. The __invoke meth...
Mapping Applying a function to all elements of an array : array_map('strtoupper', $array); Be aware that this is the only method of the list where the callback comes first. Reducing (or folding) Reducing an array to a single value : $sum = array_reduce($numbers, function ($carry, $number) { ...
MySQL's DECIMAL and NUMERIC types store exact numeric data values. It is recommended to use these types to preserve exact precision, such as for money. Decimal These values are stored in binary format. In a column declaration, the precision and scale should be specified Precision represents the n...
FLOAT and DOUBLE represent approximate data types. TypeStoragePrecisionRangeFLOAT4 bytes23 significant bits / ~7 decimal digits10^+/-38DOUBLE8 bytes53 significant bits / ~16 decimal digits10^+/-308 REAL is a synonym for FLOAT. DOUBLE PRECISION is a synonym for DOUBLE. Although MySQL also permits...
Sometimes you doesn't want to simply replace or remove the string. Sometimes you want to extract and process matches. Here an example of how you manipulate matches. What is a match ? When a compatible substring is found for the entire regex in the string, the exec command produce a match. A match i...
The POSIX and C standards explicitly state that using fflush on an input stream is undefined behavior. The fflush is defined only for output streams. #include <stdio.h> int main() { int i; char input[4096]; scanf("%i", &i); fflush(stdin); // <-- unde...
Using alarm, user can schedule SIGALARM signal to be raised after specified interval. In case user did not blocked, ignored or specified explicit signal handler for this signal, the default action for this signal will be performed on arrival. Per specification default action for SIGALARM is to termi...
Given a noisy signal: import numpy as np import matplotlib.pyplot as plt np.random.seed(1) x = np.linspace(0,2*np.pi,100) y = np.sin(x) + np.random.random(100) * 0.2 plt.plot(x,y) plt.show() one can smooth it using a Savitzky–Golay filter using the scipy.signal.savgol_filter() method...
The ranges of the integer types are implementation-defined. The header <limits> provides the std::numeric_limits<T> template which provides the minimum and maximum values of all fundamental types. The values satisfy guarantees provided by the C standard through the <climits> and (&...
If a class, enum, inline function, template, or member of a template has external linkage and is defined in multiple translation units, all definitions must be identical or the behavior is undefined according to the One Definition Rule (ODR). foo.h: class Foo { public: double x; private...
XSD schema (schema.xsd) The following xml schema (xsd) defines a list of users with attributes name and reputation. <?xml version="1.0"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns="http://www...
Review Partial Application before proceeding. In Haskell, a function that can take other functions as arguments or return functions is called a higher-order function. The following are all higher-order functions: map :: (a -> b) -> [a] -> [b] filter :: (a -> Bool) -> [a] ...
Lets say we have a class Classy that has property Propertua public class Classy { public string Propertua {get; set;} } to set Propertua using reflection: var typeOfClassy = typeof (Classy); var classy = new Classy(); var prop = typeOfClassy.GetProperty("Propertua"); prop.Se...
When editing text, a common task is to navigate to a particular word on the screen. In these examples we explore how we can navigate to the word updated. For the sake of consistency across the examples, we aim to land on the first letter of the word. Mid-screen jump M$B This approach is quick...
A topic might only apply to certain versions. When creating a new topic, the appropriate versions can be chosen in the title section of the topic. In the following example .NET 2.0, 4.0, 4.5.1; Compact Framework 3.7 and Micro Framework 4.2 are selected. This selection will show up next to the to...
An example cannot be associated with a version number directly. Parts of it can however be declared to apply only for certain versions. <!-- if version [eq Java SE 1.3] --> This content is for Java SE 1.3 <!-- end version if -->

Page 204 of 457