Functional Programming Using F# by Hansen Michael R. & Rischel Hans
Author:Hansen, Michael R. & Rischel, Hans [Hansen, Michael R.]
Language: eng
Format: epub
Publisher: Cambridge University Press
Published: 2013-04-29T22:00:00+00:00
8.4 Sequential composition
The semicolon symbol “;” denotes the sequential composition operator (while the double semicolon “;;” is a terminator symbol). This operator combines two expressions exp1 and exp2 to form a new expression:
exp1; exp2
The expression exp1 ; exp2 is evaluated as follows:
Evaluate exp1 and discard the result.
Evaluate exp2 and supply the result as the result of evaluating exp1; exp2.
Hence, if exp2 has type τ then exp1 ; exp2 has type τ as well.
The F# compiler issues a warning if exp1 is of type different from unit as the result of the evaluation might be of some use. This warning is avoided by using the ignore function:
ignore(exp1) ; exp2 or exp1|> ignore ; exp2
where ignore a = () for any value a.
We may combine two assignments using sequential composition:
let mutable x = 5;; let mutable y = 7;; x <- y + 1 ; y <- x + 2;; (x,y);; val it : int * int = (8 ,10)
Note that the second assignment uses the new value stored in the location denoted by x.
The operator “;” may be omitted if the expressions are written on separate lines, that is,
exp1
exp2
means (exp1 ) ; exp2.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12423)
Hello! Python by Anthony Briggs(9771)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9660)
The Mikado Method by Ola Ellnestam Daniel Brolund(9655)
Dependency Injection in .NET by Mark Seemann(9190)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8164)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7667)
Grails in Action by Glen Smith Peter Ledbrook(7577)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7413)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6485)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6289)
Microservices with Go by Alexander Shuiskov(6239)
Practical Design Patterns for Java Developers by Miroslav Wengner(6157)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6120)
Angular Projects - Third Edition by Aristeidis Bampakos(5468)
The Art of Crafting User Stories by The Art of Crafting User Stories(5047)
NetSuite for Consultants - Second Edition by Peter Ries(4999)
Kotlin in Action by Dmitry Jemerov(4929)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(4803)
