- 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:

- Java范例大全
- Java異步編程實戰
- Instant Typeahead.js
- Android NDK Beginner’s Guide
- Ray分布式機器學習:利用Ray進行大模型的數據處理、訓練、推理和部署
- Learning FuelPHP for Effective PHP Development
- Instant Lucene.NET
- JavaScript應用開發實踐指南
- Python 3.7從入門到精通(視頻教學版)
- 運維前線:一線運維專家的運維方法、技巧與實踐
- Java并發編程之美
- Android應用開發實戰
- Visual Basic程序設計全程指南
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)
- 嵌入式Linux C語言程序設計基礎教程