Merge pull request #3222 from lbragaglia/patch-1

[fsharp/en] Add note on equality operator
This commit is contained in:
Divay Prakash 2018-09-20 23:25:52 +05:30 committed by GitHub
commit 01140bd131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,7 +34,7 @@ let myFloat = 3.14
let myString = "hello" // note that no types needed let myString = "hello" // note that no types needed
// ------ Lists ------ // ------ Lists ------
let twoToFive = [2; 3; 4; 5] // Square brackets create a list with let twoToFive = [2; 3; 4; 5] // Square brackets create a list with
// semicolon delimiters. // semicolon delimiters.
let oneToFive = 1 :: twoToFive // :: creates list with new 1st element let oneToFive = 1 :: twoToFive // :: creates list with new 1st element
// The result is [1; 2; 3; 4; 5] // The result is [1; 2; 3; 4; 5]
@ -53,7 +53,8 @@ add 2 3 // Now run the function.
// to define a multiline function, just use indents. No semicolons needed. // to define a multiline function, just use indents. No semicolons needed.
let evens list = let evens list =
let isEven x = x % 2 = 0 // Define "isEven" as a sub function let isEven x = x % 2 = 0 // Define "isEven" as a sub function. Note
// that equality operator is single char "=".
List.filter isEven list // List.filter is a library function List.filter isEven list // List.filter is a library function
// with two parameters: a boolean function // with two parameters: a boolean function
// and a list to work on // and a list to work on