Tutorial by Examples: c

Floating point types (float, double and long double) cannot precisely represent some numbers because they have finite precision and represent the values in a binary format. Just like we have repeating decimals in base 10 for fractions such as 1/3, there are fractions that cannot be represented fini...
PREPARE prepares a statement for execution EXECUTE executes a prepared statement DEALLOCATE PREPARE releases a prepared statement SET @s = 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse'; PREPARE stmt2 FROM @s; SET @a = 6; SET @b = 8; EXECUTE stmt2 USING @a, @b; Result: +------------+ |...
You can get the value of an entry in the dictionary using the 'Item' property: Dim extensions As New Dictionary(Of String, String) From { { "txt", "notepad" }, { "bmp", "paint" }, { "doc", "winword" } } Dim program As St...
One of the most common things you'll need to do in the command prompt is navigate your file system. To do this, we'll utilize the cd and dir keywords. Start by opening up a command prompt using one of the methods mentioned here. You most likely see something similar to what's below, where UserNam...
The pickle module implements an algorithm for turning an arbitrary Python object into a series of bytes. This process is also called serializing the object. The byte stream representing the object can then be transmitted or stored, and later reconstructed to create a new object with the same charact...
Mutex locking in Go allows you to ensure that only one goroutine at a time has a lock: import "sync" func mutexTest() { lock := sync.Mutex{} go func(m *sync.Mutex) { m.Lock() defer m.Unlock() // Automatically unlock when this function returns // D...
Using the calendar module import calendar from datetime import date def monthdelta(date, delta): m, y = (date.month+delta) % 12, date.year + ((date.month)+delta-1) // 12 if not m: m = 12 d = min(date.day, calendar.monthrange(y, m)[1]) return date.replace(day=d,month=m, year=...
#include <stdio.h> #include <stdlib.h> int main (void) { int * pdata; size_t n; printf ("Enter the size of the array: "); fflush(stdout); /* Make sure the prompt gets printed to buffered stdout. */ if (1 != scanf("%zu", &n)) /* If zu is n...
Vectors in R can have different types (e.g. integer, logical, character). The most general way of defining a vector is by using the function vector(). vector('integer',2) # creates a vector of integers of size 2. vector('character',2) # creates a vector of characters of size 2. vector('logical',2...
Stanford CoreNLP is a popular Natural Language Processing toolkit supporting many core NLP tasks. To download and install the program, either download a release package and include the necessary *.jar files in your classpath, or add the dependency off of Maven central. See the download page for mor...
Adding a Conditional attribute from System.Diagnostics namespace to a method is a clean way to control which methods are called in your builds and which are not. #define EXAMPLE_A using System.Diagnostics; class Program { static void Main() { ExampleA(); // This method will ...
Before using your own object as key you must override hashCode() and equals() method of your object. In simple case you would have something like: class MyKey { private String name; MyKey(String name) { this.name = name; } @Override public boolean equals(Object ...
Creating a custom directive with isolated scope will separate the scope inside the directive from the outside scope, in order to prevent our directive from accidentally change the data in the parent scope and restricting it from reading private data from the parent scope. To create an isolated scop...
Use Kernel.inspect to convert anything to string. iex> Kernel.inspect(1) "1" iex> Kernel.inspect(4.2) "4.2" iex> Kernel.inspect %{pi: 3.14, name: "Yos"} "%{pi: 3.14, name: \"Yos\"}"
If you want to create and send signals in your own code (for example, if you are writing an extension), create a new Signal instance and call send when the subscribers should be notified. Signals are created using a Namespace. from flask import current_app from flask.signals import Namespace n...
This example shows a minimal Mockito test using a mocked ArrayList: import static org.mockito.Mockito.*; import static org.junit.Assert.*; import java.util.ArrayList; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRu...
Components are simply instances that implement the Ashley component class. import com.badlogic.ashley.core.Component; import com.badlogic.ashley.core.ComponentMapper; public class Position implements Component { public static final ComponentMapper<Position> Map = ...
Entity systems are how you perform functional operations on sets of entities. Components should typically not have logic associated with them that involves awareness of data or state of other component instances, as that is the job of an entity system. An entity system can not be registered to mor...
Closures are inline anonymous methods that have the ability to use Parent method variables and other anonymous methods which are defined in the parent's scope. In essence, a closure is a block of code which can be executed at a later time, but which maintains the environment in which it was firs...
The IEnumerable<T> interface has a single method, GetEnumerator(), which returns an IEnumerator<T>. While the yield keyword can be used to directly create an IEnumerable<T>, it can also be used in exactly the same way to create an IEnumerator<T>. The only thing that changes ...

Page 202 of 826