Tutorial by Examples

Processing tabular data with awk is very easy, provided that the input is correctly formatted. Most software producing tabular data use specific features of this family of formats, and awk programs processing tabular data are often specific to a data produced by a specific software. If a more gener...
Given a file using ; as a column delimiter. Permuting the first and the second column is accomplished by awk -F';' -v 'OFS=;' '{ swap = $2; $2 = $1; $1 = swap; print }'
Given a file using ; as a column delimiter. We compute the mean of the values in the second column with the following program, the provided input is the list of grades of a student group: awk -F';' '{ sum += $2 } END { print(sum / NR) }' <<EOF Alice;2 Victor;1 Barbara;1 Casper;4 Deborah;...
We assume a file using ; as a column delimiter. Selecting a specific set of columns only requires a print statement. For instance, the following program selects the columns 3, 4 and 7 from its input: awk -F';' -v 'OFS=;' '{ print $3, $4, $7 }' It is as usual possible to more carefully choose lin...
Given a file using ; as a column delimiter. We compute the median of the values in the second column with the following program, written for GNU awk. The provided input is the list of grades of a student group: gawk -F';' '{ sample[NR] = $2 } END { asort(sample); if(NR % 2 == 1) { p...
There are two main ways to create an axes in matplotlib: using pyplot, or using the object-oriented API. Using pyplot: import matplotlib.pyplot as plt ax = plt.subplot(3, 2, 1) # 3 rows, 2 columns, the first subplot Using the object-oriented API: import matplotlib.pyplot as plt fig = ...
Use import to specify how a namespace from one library is used in the scope of another library. import 'dart:html'; The only required argument to import is a URI specifying the library. For built-in libraries, the URI has the special dart: scheme. For other libraries, you can use a file system p...
Unlike Java, Dart doesn’t have the keywords public, protected, and private. If an identifier starts with an underscore _, it’s private to its library. If you for example have class A in a separate library file (eg, other.dart), such as: library other; class A { int _private = 0; testA()...
If you import two libraries that have conflicting identifiers, then you can specify a prefix for one or both libraries. For example, if library1 and library2 both have an Element class, then you might have code like this: import 'package:lib1/lib1.dart'; import 'package:lib2/lib2.dart' as lib2; /...
If you want to use only part of a library, you can selectively import the library. For example: // Import only foo and bar. import 'package:lib1/lib1.dart' show foo, bar; // Import all names EXCEPT foo. import 'package:lib2/lib2.dart' hide foo;
Deferred loading (also called lazy loading) allows an application to load a library on demand, if and when it’s needed. To lazily load a library, you must first import it using deferred as. import 'package:deferred/hello.dart' deferred as hello; When you need the library, invoke loadLibrary() us...
For example we have WordCountService with countWords method: class WordCountService { def countWords(url: String): Map[String, Int] = { val sparkConf = new SparkConf().setMaster("spark://somehost:7077").setAppName("WordCount")) val sc = new SparkContext(sp...
class CustomException implements Exception { String cause; CustomException(this.cause); } void main() { try { throwException(); } on CustomException { print("custom exception is been obtained"); } } throwException() { throw new CustomException('This is m...
Use pub build when you’re ready to deploy your web app. When you run pub build, it generates the assets for the current package and all of its dependencies, putting them into new directory named build. To use pub build, just run it in your package’s root directory. For example: $ cd ~/dart/hellowo...
This command starts up a development server, or dev server, for your Dart web app. The dev server is an HTTP server on localhost that serves up your web app’s assets. Start the dev server from the directory that contains your web app’s pubspec.yaml file: $ cd ~/dart/helloworld $ pub serve Servin...
iex(1)> name = "John" "John" iex(2)> greeting = "Hello, #{name}" "Hello, John" iex(3)> num = 15 15 iex(4)> results = "#{num} item(s) found." "15 item(s) found."
Fortran originally was designed for a fixed format form based on an 80 column punched card: Yes: This is a line of the author's own code These were created on a card punch machine, much like this: Images are original photography by the author The format, as shown on the illustrated sample ca...
C99 Using the system header file stdbool.h allows you to use bool as a Boolean data type. true evaluates to 1 and false evaluates to 0. #include <stdio.h> #include <stdbool.h> int main(void) { bool x = true; /* equivalent to bool x = 1; */ bool y = false; /* equivalent t...
C of all versions, will effectively treat any integer value other than 0 as true for comparison operators and the integer value 0 as false. If you don't have _Bool or bool as of C99 available, you could simulate a Boolean data type in C using #define macros, and you might still find such things in...
There are 2 ways of instantiating prefabs: during design time or runtime. Design time instantiation Instantiating prefabs at design time is useful to visually place multiple instances of the same object (e.g. placing trees when designing a level of your game). To visually instantiate a prefab...

Page 439 of 1336