F # Semantics

Source: Internet
Author: User
F #
 // The following Code demonstrates the use of reference  // Cells to enable partially applied arguments to be changed  // By Later code.  Let Increment1 delta number = Number + Delta Let   Mutable Mymutableincrement = 10 // Closures created by partial application and literals.  Let Incrementby1 = increment1 1 Let Incrementby2 = increment1 2 // Partial application of one argument from a mutable variable. Let Incrementmutable = increment1 mymutableincrementmymutableincrement <-12 // This line prints 110. Printfn "% D" (Incrementmutable 100) Let Myrefincrement = Ref 10 // Partial application of one argument, dereferenced  // From a reference cell.  Let Incrementref = increment1! Myrefincrementmyrefincrement: = 12 // This line also prints 110. Printfn "% D" (Incrementref 100)// Reset the value of the reference cell. Myrefincrement: = 10 // New increment function takes a reference cell.  Let Increment2 delta number = Number +! Delta // Partial application of one argument, passing a reference Cell  // Without dereferencing first.  Let Incrementref2 = increment2 myrefincrementmyrefincrement: = 12 // This line prints 112. Printfn "% D" (Incrementref2100)

-----------------

Let mutable x = 1let x' = XX <-2x '(OR 1, it copies x, so it will not be changed by X)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.