- Learning F# Functional Data Structures and Algorithms
- Adnan Masood Ph.D.
- 191字
- 2021-07-16 14:10:46
The Hello World example
No book is complete without some quintessential Hello World examples. So here it is:
printfn "Hello World";;
Yes, this is all you need. Notice the terseness, simplicity, and lack of clutter. Now let's run this in the F# interactive environment. In order to run it, you would need to have ";;" at the end of the statement. We will provide more details on this interactive environment setup later in Chapter 2, Now Lazily Get Over It, Again.

This is the response that you see when you run the preceding line of code. It is a minimal viable example; however these attributes of simplicity, terseness, and simplification extend beyond HelloWorld samples as you will see.
Let's look at a simple function, square. You can write a function in F# as follows:
let square = fun n -> n * n
Or you can write it in a simpler syntax like the next one. Notice the first-class citizenship in action here:
let square n = n * n
When this function is executed in F# interactive, you can immediately see the results upon invocation as in the following screenshot:

- Windows Forensics Cookbook
- 網站構建技術
- Java:High-Performance Apps with Java 9
- Learning Modular Java Programming
- Raspberry Pi Robotic Projects(Third Edition)
- 從零開始學Python網絡爬蟲
- Managing Microsoft Hybrid Clouds
- Advanced UFT 12 for Test Engineers Cookbook
- C++從入門到精通(第6版)
- 超簡單:用Python讓Excel飛起來(實戰150例)
- Mastering JavaScript
- 數字媒體技術概論
- Tableau Dashboard Cookbook
- Learning QGIS(Second Edition)
- JavaScript重難點實例精講