F#, Shadowing and Nested function

Posted by Lian on Stack Overflow See other posts from Stack Overflow or by Lian
Published on 2010-03-19T14:37:46Z Indexed on 2010/03/19 14:41 UTC
Read the original article Hit count: 107

Filed under:

Hi! Here I want to understand how the mechanism of Shadowing and Nested function work. For example:

let func y =
    let dup y = y + y
    let z = dup y
    let dup y =
        let dup z =
            let y = y * z
            y
        let z = y
        y
    dup z + z;;

val func : int -> int

> func 3;;
val it : int = 12

Can someone explain what happen here?

© Stack Overflow or respective owner

Related posts about F#