Tutorial by Examples: df

If a function contains just one expression, we can omit the brace brackets and use an equals instead, like a variable assignment. The result of the expression is returned automatically. fun sayMyName(name: String): String = "Your name is $name"
To temporarily mark a file as ignored (pass file as parameter to alias) - type: unwatch = update-index --assume-unchanged To start tracking file again - type: watch = update-index --no-assume-unchanged To list all files that has been temporarily ignored - type: unwatched = "!git ls-fil...
Sometimes it's necessary to convert a Discriminated Union to and from a string: module UnionConversion open Microsoft.FSharp.Reflection let toString (x: 'a) = match FSharpValue.GetUnionFields(x, typeof<'a>) with | case, _ -> case.Name let fromStri...
A tbl_df (pronounced tibble diff) is a variation of a data frame that is often used in tidyverse packages. It is implemented in the tibble package. Use the as_data_frame function to turn a data frame into a tbl_df: library(tibble) mtcars_tbl <- as_data_frame(mtcars) One of the most notable ...
Functions can either be named or unnamed (anonymous functions): var namedSum = function sum (a, b) { // named return a + b; } var anonSum = function (a, b) { // anonymous return a + b; } namedSum(1, 3); anonSum(1, 3); 4 4 But their names are private to their own scope: ...
<?php namespace models; use yii\db\ActiveRecord; use yii\behaviors\TimestampBehavior; class Post extends ActiveRecord { public static function tableName() { return 'post'; } public function rules() { ...
The following will list up to ten of the most recently modified files in the current directory, using a long listing format (-l) and sorted by time (-t). ls -lt | head
The strchr and strrchr functions find a character in a string, that is in a NUL-terminated character array. strchr return a pointer to the first occurrence and strrchr to the last one. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char toSe...
def multiply(factor: Int)(numberToBeMultiplied: Int): Int = factor * numberToBeMultiplied val multiplyBy3 = multiply(3)_ // resulting function signature Int => Int val multiplyBy10 = multiply(10)_ // resulting function signature Int => Int val sixFromCurriedCall = multiplyBy3(2) //6...
public void iterateAndFilter() throws IOException { Path dir = Paths.get("C:/foo/bar"); PathMatcher imageFileMatcher = FileSystems.getDefault().getPathMatcher( "regex:.*(?i:jpg|jpeg|png|gif|bmp|jpe|jfif)"); try (Direc...
Model with ForeignKey We will work with these models : from django.db import models class Book(models.Model): name= models.CharField(max_length=50) author = models.ForeignKey(Author) class Author(models.Model): name = models.CharField(max_length=50) Suppose we often (always) access ...
The ROUND function rounds a value. The number of decimal places to round to is specified by a positive value in the num_digits parameter. A negative value for the num_digits will round the integer portion of the value left of the decimal point, e.g. to the nearest 10 (for -1) or to the nearest 1000 ...
The Excel function MROUND is used to round a number to an interval other than a power of 10. These examples show MROUND to the nearest quarter and to the nearest even number. Starting withMROUND(b,0.25)MROUND(b,2)23.9319521124.00242.7931353882.75221.9390306422.002213.7419373913.751416.7704741216.7...
package { import flash.display.Sprite; import flash.events.Event; public class Viewport extends Sprite { /** Constructor */ public function Viewport() { super(); // Listen for added to stage event addEventListener(Event.ADDED_TO_STAGE, addedToStageHandle...
Returning partially applied functions is one technique to write concise code. add :: Int -> Int -> Int add x = (+x) add 5 2 In this example (+x) is a partially applied function. Notice that the second parameter to the add function does not need to be specified in the function definitio...
Let's suppose we have a reference to the JQuery type definition and we want to extend it to have additional functions from a plugin we included and which doesn't have an official type definition. We can easily extend it by declaring functions added by plugin in a separate interface declaration with ...
s=this.getChildByName("garbage"); if (s.parent==this) {...} getChildByName() is one of the many functions that can return null if an error occurred when processing its input. Therefore, if you are receiving an object from any function that can possibly return null, check for null first...
Create generic class instance: var stringRunnable = new Runnable<string>(); Run generic function: function runSafe<T extends Runnable<U>, U>(runnable: T); // Specify the generic types: runSafe<Runnable<string>, string>(stringRunnable); // Let typescript figu...
Make sure to have a file input on your page: <input type="file" id="upload"> Then in JavaScript: document.getElementById('upload').addEventListener('change', readFileAsString) function readFileAsString() { var files = this.files; if (files.length === 0) { ...

Page 3 of 21