R
RT1138
Guest
Phillip Carter did a demo at build (I'm watching the recording-Binary Search Tree) which was this
type BST<'T> =
|Empty
|Node of value:'T*left:BST<'T> * right:BST<'T>
let rec flip bst =
match bst with
| Empty -> bst
|Node(x,left,right)-> Node(x, flip right, flip left)
[<EntryPoint>]
let main argv =
let bst = Node(4, Node(3, Empty,Empty), Node(5,Empty,Empty))
let flipped = flip bst
prntfn "BST: %A \nFlipped: %A\n\n" bst flipped
0
The code shows errors in the bold code above. When I try to run the code, this is what I get
Welcome to Try F# 3.0
For additional help: http://www.tryfsharp.org/Help
>
type BST<'T> =
|Empty
|Node of value: 'T*left:BST<'T> * right:BST<'T>
let rec flip bst =
match bst with
| Empty -> bst
|Node(x,left,right)-> Node(x, flip right, flip left)
[<EntryPoint>]
[... and 7 more line(s)]
|Node of value: 'T*left:BST<'T> * right:BST<'T>
------------------^
stdin(3,19): error FS0010: Unexpected symbol ':' in member definition
>
So, Is the website using VS2012 F# and more up to date code won't work? The code did work in his demo but not here.
Thanks
Continue reading...
type BST<'T> =
|Empty
|Node of value:'T*left:BST<'T> * right:BST<'T>
let rec flip bst =
match bst with
| Empty -> bst
|Node(x,left,right)-> Node(x, flip right, flip left)
[<EntryPoint>]
let main argv =
let bst = Node(4, Node(3, Empty,Empty), Node(5,Empty,Empty))
let flipped = flip bst
prntfn "BST: %A \nFlipped: %A\n\n" bst flipped
0
The code shows errors in the bold code above. When I try to run the code, this is what I get
Welcome to Try F# 3.0
For additional help: http://www.tryfsharp.org/Help
>
type BST<'T> =
|Empty
|Node of value: 'T*left:BST<'T> * right:BST<'T>
let rec flip bst =
match bst with
| Empty -> bst
|Node(x,left,right)-> Node(x, flip right, flip left)
[<EntryPoint>]
[... and 7 more line(s)]
|Node of value: 'T*left:BST<'T> * right:BST<'T>
------------------^
stdin(3,19): error FS0010: Unexpected symbol ':' in member definition
>
So, Is the website using VS2012 F# and more up to date code won't work? The code did work in his demo but not here.
Thanks
Continue reading...