Tutorial by Examples

Most functions in F# are created with the let syntax: let timesTwo x = x * 2 This defines a function named timesTwo that takes a single parameter x. If you run an interactive F# session (fsharpi on OS X and Linux, fsi.exe on Windows) and paste that function in (and add the ;; that tells fsharpi ...
It is possible to find the first element of a Stream that matches a condition. For this example, we will find the first Integer whose square is over 50000. IntStream.iterate(1, i -> i + 1) // Generate an infinite stream 1,2,3,4... .filter(i -> (i*i) > 50000) // Filter to find element...
Template JS code Template.templateName.onCreated(function(){ this.subscribe('subsription1'); this.subscribe('subscription2'); }); Template HTML code <template name="templateName"> {{#if Template.subscriptionsReady }} //your actual view with data. it can ...
Variables can be incremented or decremented by 1 with ++ or --, respectively. They can either precede or succeed variables and slightly vary semantically, as shown below. $i = 1; echo $i; // Prints 1 // Pre-increment operator increments $i by one, then returns $i echo ++$i; // Prints 2 // P...
Concept Use an Event to synchronize the scheduling of multiple coroutines. Put simply, an event is like the gun shot at a running race: it lets the runners off the starting blocks. Example import asyncio # event trigger function def trigger(event): print('EVENT SET') event.set() #...
Electron ports HTML web applications to native applications for a range of devices, including creating native desktop applications. It's also very easy to get started! To begin, we must have electron, nodejs, npm, git and meteor installed. Familiarity with these tools is vital for working with Mete...
Let's download a Meteor Todos example project, using a Linux shell (command line) script, to test out Electrifying a project for the first time: Requirements for this section: Git apt-get install git-all There are many ways to install Git. Check them out here. git is a version control sys...
Defining our terms By array here we mean a Lua table used as a sequence. For example: -- Create a table to store the types of pets we like. local pets = {"dogs", "cats", "birds"} We're using this table as a sequence: a group of items keyed by integers. Many langua...
Installing Angular Material npm npm install angular-material --save bower bower install angular-material --save jspm jspm install angular-material From Cloud cdnjs | jsdelivr | googlecdn Getting Started (blank shell) <html lang="en"> <head> <meta name...
Files: - example.rs (root of our modules tree, generally named lib.rs or main.rs when using Cargo) - first.rs - second/ - mod.rs - sub.rs Modules: - example -> example - first -> example::first - second -> example::second - sub -> exampl...
Given that the function has a proper prototype, integers are widened for calls to functions according to the rules of integer conversion, C11 6.3.1.3. 6.3.1.3 Signed and unsigned integers When a value with integer type is converted to another integer type other than _Bool, if the value can be r...
Pointer conversions to void* are implicit, but any other pointer conversion must be explicit. While the compiler allows an explicit conversion from any pointer-to-data type to any other pointer-to-data type, accessing an object through a wrongly typed pointer is erroneous and leads to undefined beh...
It's fairly common that you may create a class that implements IDisposable, and then derive classes that also contain managed resources. It is recommendeded to mark the Dispose method with the virtual keyword so that clients have the ability to cleanup any resources they may own. public class Paren...
This example wraps the asynchronous method oauth2.client.getToken(callback) from the package NPM package simple-oauth2into a Fiber so that the method may be called synchronously. const oauth2 = require('simple-oauth2')(credentials); const credentials = { clientID: '#####', clientSecret...

Zip

The Zip extension method acts upon two collections. It pairs each element in the two series together based on position. With a Func instance, we use Zip to handle elements from the two C# collections in pairs. If the series differ in size, the extra elements of the larger series will be ignored. To...
Customer[] customers = Customers.ToArray(); Purchase[] purchases = Purchases.ToArray(); var groupJoinQuery = from c in customers join p in purchases on c.ID equals p.CustomerID into custPurchases select new { CustName = c.Name, custPurchases }; ...
ElementAt will return the item at index n. If n is not within the range of the enumerable, throws an ArgumentOutOfRangeException. int[] numbers = { 1, 2, 3, 4, 5 }; numbers.ElementAt(2); // 3 numbers.ElementAt(10); // throws ArgumentOutOfRangeException ElementAtOrDefault will return the item...
Quantifier operations return a Boolean value if some or all of the elements in a sequence satisfy a condition. In this article, we will see some common LINQ to Objects scenarios where we can use these operators. There are 3 Quantifiers operations that can be used in LINQ: All – used to determine w...
Streams of elements usually do not allow access to the index value of the current item. To iterate over an array or ArrayList while having access to indexes, use IntStream.range(start, endExclusive). String[] names = { "Jon", "Darin", "Bauke", "Hans", "M...
An interesting thing to note which may help optimize your applications is that primitives are actually also refcounted under the hood. Let's take a look at numbers; for all integers between -5 and 256, Python always reuses the same object: >>> import sys >>> sys.getrefcount(1) 7...

Page 316 of 1336