Nesting

Function and variable definitions can be structured hierarchically within an F# program, allowing some definitions to be globally visible, others to be defined separately in distinct portions of the hierarchy, others to be visible only within a single branch of the hierarchy and others to be refined, specialising them within the hierarchy. Compared to writing a program as a flat list of function and variable definitions, structuring a program into a hierarchy of definitions allows the number of dependencies within the program to be managed as the size and complexity of the programs grows.
This is achieved most simply by nesting definitions. Thus, nesting is the simplest approach to the structuring of programss. For example, the ipow3 function defined in the previous chapter contains a nested definition of a function sqr:


> let ipow3 x =
let sqr x = x * x
x * sqr x;;
val ipow3 : int -> int

The nested function sqr is only “visible” within the remainder of the definition of ipow3 and cannot be used outside this function. This capability is particularly useful when part of a function is best factored out into an auxiliary function that has no meaning or use outside its parent function. Nesting an auxiliary function can improve clarity without polluting the external namespace, e.g. with a definition ipow3-aux. Nesting can be more productively exploited when combined with the factoring of subexpressions, functions and higher-order functions.
READ MORE - Nesting

I am Back

CUMAN MAU BERSIH2 BLOG NICH.. NTAR AJA BUAT BLOGNya... I am BACK...
READ MORE - I am Back

Check PAGE RANK

Check Page Rank of your Web site pages instantly:

This page rank checking tool is powered by Page Rank Checker service

CHECK THIS OUT

About Me

Foto saya
Bukan Orang BAIK. Tapi Juga Bukan Orang JAHAT, APALAGI Munafik.