Tutorial by Examples: c

A std::string containing a number can be converted into an integer type, or a floating point type, using conversion functions. Note that all of these functions stop parsing the input string as soon as they encounter a non-numeric character, so "123abc" will be converted into 123. The s...
Arithmetic operations are performed elementwise on Numpy arrays. For arrays of identical shape, this means that the operation is executed between elements at corresponding indices. # Create two arrays of the same size a = np.arange(6).reshape(2, 3) b = np.ones(6).reshape(2, 3) a # array([0, 1...
app/pipes.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'truthy'}) export class Truthy implements PipeTransform { transform(value: any, truthy: string, falsey: string): any { if (typeof value === 'boolean'){return value ? truthy : falsey;} else return va...
import random probability = 0.3 if random.random() < probability: print("Decision with probability 0.3") else: print("Decision with probability 0.7")
Instantiating a socket can be done in various ways. by 2 line declaration & instantiation: First we need to define a variable which will hold a Socket class object: Socket socket; then we can create a Socket class object: socket = new Socket(); We can also make a one line defin...
The simplest way to run your job is to use mpiexec or mpirun (they are usually the same thing and aliases of each other). mpiexec -n 2 ./my_prog
Installing aws cli in Ubuntu / Debian Instance sudo apt-get install -y python-dev python-pip sudo pip install awscli aws --version aws configure Installing aws cli using python Using pip you can install aws cli in windows, OS X and Linux sudo pip install awscli Configuring the AWS Comman...
A subprogram (which defines a procedure), can be either a subroutine or a function; it is said to be an internal subprogram if it is called or invoked from the same program or subprogram that contains it, as follows program my_program ! declarations ! executable statements, ! among which...
A subprogram is said to be external when it is not contained in the main program, nor in a module or antoher subprogram. In particular it can be defined by means of a programming language other than Fortran. When an external subprogram is invoked, the compiler cannot access to its code, so all the ...
Most advanced user interfaces require the user to be able to pass information between the various functions which make up a user interface. MATLAB has a number of different methods to do so. guidata MATLAB's own GUI Development Environment (GUIDE) prefers to use a struct named handles to pass da...
Controlled form components are defined with a value property. The value of controlled inputs is managed by React, user inputs will not have any direct influence on the rendered input. Instead, a change to the value property needs to reflect this change. class Form extends React.Component { con...
Uncontrolled components are inputs that do not have a value property. In opposite to controlled components, it is the application's responsibility to keep the component state and the input value in sync. class Form extends React.Component { constructor(props) { super(props); th...
There are various methods available for explicitly converting a string to an integer, such as: Convert.ToInt16(); Convert.ToInt32(); Convert.ToInt64(); int.Parse(); But all these methods will throw a FormatException, if the input string contains non-numeric characters. For t...
Floating-point numbers cannot represent all real numbers. This is known as floating point inaccuracy. There are infinitely many floating points numbers and they can be infinitely long (e.g. π), thus being able to represent them perfectly would require infinitely amount of memory. Seeing this was a ...
To add/subtract time, use POSIXct, since it stores times in seconds ## adding/subtracting times - 60 seconds as.POSIXct("2016-01-01") + 60 # [1] "2016-01-01 00:01:00 AEDT" ## adding 3 hours, 14 minutes, 15 seconds as.POSIXct("2016-01-01") + ( (3 * 60 * 60) + (14 ...
Objective-C NSString *textToShare = @"StackOverflow Documentation!! Together, we can do for Documentation what we did for Q&A."; NSURL *documentationURL = [NSURL URLWithString:@"http://stackoverflow.com/tour/documentation"]; NSArray *objectsToShare = @[textToShare, docum...
Steps to create Hello Spring: Investigate Spring Boot to see if that would better suit your needs. Have a project set up with the correct dependencies. It is recommended that you are using Maven or Gradle. create a POJO class, e.g. Employee.java create a XML file where you can define your clas...
You can remove any of the conventions defined in the System.Data.Entity.ModelConfiguration.Conventions namespace, by overriding OnModelCreating method. The following example removes PluralizingTableNameConvention. public class EshopContext : DbContext { public DbSet<Product> Products...
for comprehensions in Scala are just syntactic sugar. These comprehensions are implemented using the withFilter, foreach, flatMap and map methods of their subject types. For this reason, only types that have these methods defined can be utilized in a for comprehension. A for comprehension of the fo...
It is also possible to use Scala's string interpolation feature to create elaborate extractors (pattern matchers), as perhaps most famously employed in the quasiquotes API of Scala macros. Given that n"p0${i0}p1" desugars to new StringContext("p0", "p1").n(i0), it is p...

Page 227 of 826