Tutorial by Examples: c

Assume the following enum: enum Operation { Multiply(left : Int, right : Int); } Enum matching can be performed as follows: var result = switch(Multiply(1, 3)) { case Multiply(_, 0): 0; case Multiply(0, _): 0; case Multiply(l, r): l * r; } Ref...
Assume the following structure: var dog = { name : "Woofer", age : 7 }; Enum matching can be performed as follows: var message = switch(dog) { case { name : "Woofer" }: "I know you, Woofer!"; case _: "I don't know you, so...
var result = switch([1, 6]) { case [2, _]: "0"; case [_, 6]: "1"; case []: "2"; case [_, _, _]: "3"; case _: "4"; } References "Array matching", Haxe manual
Extractors are identified by the extractorExpression => match expression. Extractors consist of two parts, which are separated by the => operator. The left side can be any expression, where all occurrences of underscore _ are replaced with the currently matched value. The right side is a p...
This relies on the official consul docker image to run consul in clustered mode in a docker swarm with new swarm mode in Docker 1.12. This example is based on http://qnib.org/2016/08/11/consul-service/. Briefly the idea is to use two docker swarm services that talk to each other. This solves the pro...
This is example has extracted from this boilerplate. Custom middleware: export default function clientMiddleware() { return ({dispatch, getState}) => { return next => action => { if (typeof action === 'function') { return action(dispatch, getState); } ...
(Tested with ANTLR 4.5.3, Eclipse Neon, ANTLR 4 IDE 0.3.5, and Java 1.8) Download the latest ANTLR. Make sure to get the complete ANTLR Java binaries jar. Save to any appropriate location, for example the folder where other Java libraries are stored. It doesn’t matter where, just remember the loc...
Dependency resolver is used to avoid tightly-coupled classes, improve flexibility and make testing easy. You can create your own dependency injector (not recomended) or use one of well-written and tested dependency injectors. In this example I am going to use Ninject. Step one: Create dependency re...
Tk is the absolute root of the application, it is the first widget that needs to be instantiated and the GUI will shut down when it is destroyed. Toplevel is a window in the application, closing the window will destroy all children widgets placed on that window{1} but will not shut down the program...
The most basic case to lift a particular window above the others, just call the .lift() method on that window (either Toplevel or Tk) import tkinter as tk #import Tkinter as tk #change to commented for python2 root = tk.Tk() for i in range(4): #make a window with a label window = tk...
Analog to np.loadtxt, np.savetxt can be used to save data in an ASCII file import numpy as np x = np.random.random([100,100]) np.savetxt("filename.txt", x) To control formatting: np.savetxt("filename.txt", x, delimiter=", " , newline="\n", comment...
' Just setting up the example Public Class A Public Property ID as integer Public Property Name as string Public Property OtherValue as Object End Class Public Sub Example() 'Setup the list of items Dim originalList As New List(Of A) originalList.Add(New A() With {...
Setup After setting up a simple project to use webpack, babel and react issuing $npm i -g webpack-dev-server will install the development http server for quicker development. Modifying webpack.config.js var path = require('path'); module.exports = { entry: './src/index.js', output: { ...
This creates a window in fullscreen with size 500x500 pixels: pygame.init() screen = pygame.display.set_mode((500, 500), pygame.FULLSCREEN) screen represents from now on the window on screen; it is a pygame.Surface object. Anything that should be come visible to the user has to be drawn onto it...
A cycle in a directed graph exists if there's a back edge discovered during a DFS. A back edge is an edge from a node to itself or one of the ancestors in a DFS tree. For a disconnected graph, we get a DFS forest, so you have to iterate through all vertices in the graph to find disjoint DFS trees. ...
Variance measures how far a set numbers is spread out from it's mean. From practical perspective it is squared distance from its mean (center) - the bigger the number the farther the point is. The following example would return variance of salary values SELECT name, salary, VARIANCE(salary) "...
A check box displays a single option that the user can either check or uncheck and radio buttons present a group of options from which the user can select just one option. To create a group of radio buttons, you specify the same name for the GroupName attribute of each radio button in the group. If...
ASP.NET provides the following controls Drop-down list List box Radio button list Check box list Bulleted list These control let a user choose from one or more items from the list. List boxes and drop-down lists contain one or more list items. These lists can be loaded either by code or b...
A radio button list presents a list of mutually exclusive options. A check box list presents a list of independent options. These controls contain a collection of ListItem objects that could be referred to through the Items property of the control. Basic syntax of radio button list: <asp:RadioB...
The HyperLink control is like the HTML element. Basic syntax for a hyperlink control: <asp:HyperLink ID="HyperLink1" runat="server"> HyperLink </asp:HyperLink> It has the following important properties: PropertiesDescriptionImageUrlPath of the image to be ...

Page 548 of 826