Tutorial by Examples

In this example we will calculate the squared deviance for each column in a data frame, in this case the mtcars. Option A: integer index squared_deviance <- vector("list", length(mtcars)) for (i in seq_along(mtcars)){ squared_deviance[[i]] <- (mtcars[[i]] - mean(mtcars[[i]]))^2...
To illustrate the effect of good for loop construction, we will calculate the mean of each column in four different ways: Using a poorly optimized for loop Using a well optimized for for loop Using an *apply family of functions Using the colMeans function Each of these options will be shown...
<div [class.active]="isActive"></div> <span [style.color]="'red'"></span> <p [attr.data-note]="'This is value for data-note attribute'">A lot of text here</p>
import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: ` <h1>Angular 2 App</h1> <p>Component is directive with template</p> ` }) export class AppComponent { }
<div *ngFor="let item of items">{{ item.description }}</div> <span *ngIf="isVisible"></span>
import {Directive, ElementRef, Renderer} from '@angular/core'; @Directive({ selector: '[green]', }) class GreenDirective { constructor(private _elementRef: ElementRef, private _renderer: Renderer) { _renderer.setElementStyle(_elementRef.nativeElement, 'color', 'gree...
By default, ui-router encodes the slash / inside parameters. If you want to send a path in the URL, you need to define a custom parameter type. Define: module.config(['$urlMatcherFactoryProvider', function($urlMatcherFactory) { $urlMatcherFactory.type('path', { decode: function(val) { retu...
A complete Fortran program is made up from a number of distinct program units. Program units are: main program function or subroutine subprogram module or submodule block data program unit The main program and some procedure (function or subroutine) subprograms may be provided by a languag...
Modules are documented elsewhere. Compilers often generate so-called module files: usually the file containing module my_module end module will result in a file named something like my_module.mod by the compiler. In such cases, for a module to be accessible by a program unit, that module file...
An external procedure is one which is defined outside another program unit, or by a means other than Fortran. The function contained in a file like integer function f() implicit none end function f is an external function. For external procedures, their existence may be declared by using a...
Block data program units are program units which provide initial values for objects in common blocks. These are deliberately left undocumented here, and will feature in the documentation of historic Fortran features.
A program unit which is not an internal subprogram may contain other program units, called internal subprograms. program prog implicit none contains function f() end function f subroutine g() end subroutine g end program Such an internal subprogram has a number of features: t...
iex> ~w(a b c) ["a", "b", "c"]
iex> ~w(a b c)a [:a, :b, :c]
From within a generator function, the control can be delegated to another generator function using yield*. function* g1() { yield 2; yield 3; yield 4; } function* g2() { yield 1; yield* g1(); yield 5; } var it = g2(); console.log(it.next()); // 1 console.log(it.next())...
The Observer pattern is used for event handling and delegation. A subject maintains a collection of observers. The subject then notifies these observers whenever an event occurs. If you've ever used addEventListener then you've utilized the Observer pattern. function Subject() { this.observers...
for a large number of files which may need to be operated on in a similar process and with well structured file names. firstly a vector of the file names to be accessed must be created, there are multiple options for this: Creating the vector manually with paste0() files <- paste0("f...
#include <stdio.h> #define ARRLEN (10) int main (void) { int n[ ARRLEN ]; /* n is an array of 10 integers */ size_t i, j; /* Use size_t to address memory, that is to index arrays, as its guaranteed to be wide enough to address all of the possible availab...
You should have Elm platform installed on your computer, the following tutorial is written with the assumption, that you are familiar with terminal. Initialization Create a folder and navigate to it with your terminal: $ mkdir elm-app $ cd elm-app/ Initialize Elm project and install core depe...
A distinctive syntactic peculiarity of C is that declarations mirror the use of the declared object as it would be in a normal expression. The following set of operators with identical precedence and associativity are reused in declarators, namely: the unary * "dereference" operator wh...

Page 271 of 1336