- 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 EE 6 企業級應用開發教程
- 軟件測試工程師面試秘籍
- Python零基礎快樂學習之旅(K12實戰訓練)
- 21天學通C++(第6版)
- 算法訓練營:提高篇(全彩版)
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- UI設計全書(全彩)
- Illustrator CS6設計與應用任務教程
- Arduino可穿戴設備開發
- JQuery風暴:完美用戶體驗
- Python 3 Object:oriented Programming(Second Edition)
- 精通Spring:Java Web開發與Spring Boot高級功能
- Web前端開發精品課:HTML5 Canvas開發詳解
- 數據庫技術及應用教程上機指導與習題(第2版)
- Python GUI設計tkinter菜鳥編程(增強版)