Tutorial by Examples: c

Pattern matching on tuples uses the tuple constructors. To match a pair for example, we'd use the (,) constructor: myFunction1 (a, b) = ... We use more commas to match tuples with more components: myFunction2 (a, b, c) = ... myFunction3 (a, b, c, d) = ... Tuple patterns can contain comple...
Use the fst and snd functions (from Prelude or Data.Tuple) to extract the first and second component of pairs. fst (1, 2) -- evaluates to 1 snd (1, 2) -- evaluates to 2 Or use pattern matching. case (1, 2) of (result, _) => result -- evaluates to 1 case (1, 2) of (_, result) => resu...
Use the uncurry function (from Prelude or Data.Tuple) to convert a binary function to a function on tuples. uncurry (+) (1, 2) -- computes 3 uncurry map (negate, [1, 2, 3]) -- computes [-1, -2, -3] uncurry uncurry ((+), (1, 2)) -- computes 3 map (uncurry (+)) [(1, 2), (3, 4), (5, 6)] -- co...
Use the curry function (from Prelude or Data.Tuple) to convert a function that takes tuples to a function that takes two arguments. curry fst 1 2 -- computes 1 curry snd 1 2 -- computes 2 curry (uncurry f) -- computes the same as f import Data.Tuple (swap) curry swap 1 2 -- computes (2, 1...
Use swap (from Data.Tuple) to swap the components of a pair. import Data.Tuple (swap) swap (1, 2) -- evaluates to (2, 1) Or use pattern matching. case (1, 2) of (x, y) => (y, x) -- evaluates to (2, 1)
Android Activity package com.example.myapp; import android.os.Bundle; import android.app.Activity; import android.webkit.WebView; public class WebViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceSta...
Basic Example package com.example.myapp; import android.os.Bundle; import android.app.Activity; import android.webkit.WebView; public class WebViewActivity extends Activity { private Webview webView; @Override protected void onCreate(Bundle savedInstanceState) { ...
A. The syntax is presented above. The following selector matches all <input> elements in an HTML document that are not disabled and don't have the class .example: HTML: <form> Phone: <input type="tel" class="example"> E-mail: <input type="em...
The :only-child CSS pseudo-class represents any element which is the only child of its parent. HTML: <div> <p>This paragraph is the only child of the div, it will have the color blue</p> </div> <div> <p>This paragraph is one of the two children of the ...
Caffe has a build-in input layer tailored for image classification tasks (i.e., single integer label per input image). This input "Data" layer is built upon an lmdb or leveldb data structure. In order to use "Data" layer one has to construct the data structure with all training d...
Using comments in your projects is a handy way of leaving explanations of your design choices, and should aim to make your (or someone else's) life easier when maintaining or adding to the code. There are a two ways of adding a comment to your code. Single line comments Any text placed after // w...
By default, LESS will use its own calc() unless told otherwise. So: @column-count: 2; .class-example { width: calc(100% / @column-count); } Would compile to this: .class-example { width: 50%; } While it is our desired width, LESS has used it's own calc() function to calculate ...
RSA can be used to create a message signature. A valid signature can only be generated with access to the private RSA key, validating on the other hand is possible with merely the corresponding public key. So as long as the other side knows your public key they can verify the message to be signed by...
Asymmetric encryption has the advantage that a message can be encrypted without exchanging a secret key with the recipient of the message. The sender merely needs to know the recipients public key, this allows encrypting the message in such a way that only the designated recipient (who has the corre...
The GNU gprof profiler, gprof, allows you to profile your code. To use it, you need to perform the following steps: Build the application with settings for generating profiling information Generate profiling information by running the built application View the generated profiling inf...
1. Jenkins : Jenkins is an open source continuous integration tool written in Java. The project was forked from Hudson after a dispute with Oracle. In a nutshell, Jenkins is the leading open source automation server. Built with Java, it provides hundreds of plugins to support building, testing, de...
Setup Spark context in R To start working with Sparks distributed dataframes, you must connect your R program with an existing Spark Cluster. library(SparkR) sc <- sparkR.init() # connection to Spark context sqlContext <- sparkRSQL.init(sc) # connection to SQL context Here are infos how...
What: Caching can optimize computation in Spark. Caching stores data in memory and is a special case of persistence. Here is explained what happens when you cache an RDD in Spark. Why: Basically, caching saves an interim partial result - usually after transformations - of your original data. So, ...
SQL Server 2012 In Transact SQL , you may define an object as Date (or DateTime) using the [DATEFROMPARTS][1] (or [DATETIMEFROMPARTS][1]) function like following: DECLARE @myDate DATE=DATEFROMPARTS(1988,11,28) DECLARE @someMoment DATETIME=DATEFROMPARTS(1988,11,28,10,30,50,123) The parameter...
If you'd like to quickly test if an ability class is giving the correct permissions, you can initialize an ability in the console or on another context with the rails environment loaded, just pass an user instance to test against: test_ability = Ability.new(User.first) test_ability.can?(:show, Pos...

Page 460 of 826