Tutorial by Examples: def

Since every Applicative Functor is a Functor, fmap can always be used on it; thus the essence of Applicative is the pairing of carried contents, as well as the ability to create it: class Functor f => PairingFunctor f where funit :: f () -- create a context, carrying nothing ...
For more complicated projects, or in cases where you intend to gradually type a dependency, it may be cleaner to create a module. Using JQuery (although it does have typings available) as an example: // place in jquery.d.ts declare let $: any; export default $; And then in any file in your pr...
#import <Foundation/Foundation.h> int main() { NSLog(@"File :%s\n", __FILE__ ); NSLog(@"Date :%s\n", __DATE__ ); NSLog(@"Time :%s\n", __TIME__ ); NSLog(@"Line :%d\n", __LINE__ ); NSLog(@"ANSI :%d\n", __STDC__ ); ...
The very first line in each of your LaTeX programs should do this. It should follow the form \documentclass{...}. What you put within the curly braces is very important. Some document classes give you extra commands to use, others use a different format, and all have specific parameters you can inp...
You can make your plugin customizable by accepting options. $.fn.colourize = function(options) { // This is one method to support default options var style = $.extend({ color: "green", backgroundColor: "white" }, options); // Set the col...
JavaScript allows us to define getters and setters in the object literal syntax. Here's an example: var date = { year: '2017', month: '02', day: '27', get date() { // Get the date in YYYY-MM-DD format return `${this.year}-${this.month}-${this.day}` }, ...
var setValue; var obj = {}; Object.defineProperty(obj, "objProperty", { get: function(){ return "a value"; }, set: function(value){ setValue = value; } });
<?php namespace App; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * Get the user's first name. * * @param string $value * @return string */ public function getFirstNameAttribute($value) { return ucfirst($v...
class User extends Model { public function setPasswordAttribute($password) { $this->attributes['password'] = bcrypt($password); } ... } Above code does "bcrypting" each time password property is set. $user = $users->first(); $user->password ...
If you have a ActiveRecord User class with name and email attributes, you could create a factory for it by making the FactoryGirl guess it: FactoryGirl.define do factory :user do # it will guess the User class name "John" email "[email protected]" end end ...
So the main goal of this function is to : Be standalone because it needs to be written in the main VbScript file and cannot be in an included file (because it defines the include function) Provide enough information if something goes wrong (ie. the file that was being included, the error that oc...
Using named ranges allows you to describe the meaning of a cell(s) contents and use this defined name in place of an actual cell address. For example, formula =A5*B5 can be replaced with =Width*Height to make the formula much easier to read and understand. To define a new named range, select cell ...
function addTwo(a, b = 2) { return a + b; } addTwo(3) // Returns the result 5 With the addition of default function parameters you can now make arguments optional and have them default to a value of your choice.
You can pass parameters to the functions in tf.cond() using lambda and the code is as bellow. x = tf.placeholder(tf.float32) y = tf.placeholder(tf.float32) z = tf.placeholder(tf.float32) def fn1(a, b): return tf.mul(a, b) def fn2(a, b): return tf.add(a, b) pred = tf.placeholder(tf....
Different platforms can have separate implementations of the same method. This example also illustrates how build tags and file suffixes can be used together. File main.go: package main import "fmt" func main() { fmt.Println("Hello World from Conditional Compilation Doc!&...
<RangeSeekBar android:id="@+id/barPrice" android:layout_width="fill_parent" android:layout_height="wrap_content" app:barHeight="0.2dp" app:barHeight2="4dp" app:increment="7" ...
@Mojo(name = "hi", defaultPhase = LifecyclePhase.COMPILE)
While good software design often maximizes code reusability, sometimes it can be useful to define asynchronous tasks inline in your code via Lambda expressions to maximize code readability. In this example, we will create a single class which contains a main() method. Inside this method, we will us...
var indexController = myApp.controller("indexController", function ($scope) { // Application logic goes here });
To simply open a URL, use the webbrowser.open() method: import webbrowser webbrowser.open("http://stackoverflow.com") If a browser window is currently open, the method will open a new tab at the specified URL. If no window is open, the method will open the operating system's default b...

Page 22 of 27