![]() |
Edit |
![]() |
|
![]() |
Recent Changes |
![]() |
Subscriptions |
![]() |
Lost and Found |
![]() |
Find References |
![]() |
Rename |
| Search |
![]() |
List all versions |
Check out the formatting tips on the right for help formatting and making links.
Use the template below:
People frequently want to write code that contains embedded actions (also called statements, i.e. the code is imperative - in F# these are just expressions that return the type "unit", which is here essentially equivalent to the type "void"). Here are some guidelines for which constructs to use to write that code.
<statement>; <statement>; <statement>
("<statement>" is an expression with type "unit" - i.e. "void").
let f x =
<statement>;
let y = <expression> in
let z = <expression> in
<statement>;
<expr>
In terms of cost each "let" binding is just like declaring a local in C# with some initialization code. That is, multiple "let/in" pairs are not expensive, and nor is nesting them.
if x then (
<statement>;
<statement>
) else (
<statement>;
<statement>
)
if x then begin
<statement>;
<statement>
end else begin
<statement>;
<statement>
end
begin match x with
| A ->
<statement>;
| B ->
<statement>;
end;
<statement>
let _ = <statement> in let _ = <statement> in
type C =
class
val id: string
new(id) =
{ id = id }
then
printf "the object has been initialized\n"
do <statement> let _ = <statement> let x = 1;; x+x;;
![]() |
| This site supports the new NoFollow anti-spam initiative. |
Recent Topics