Skip to Content
Programming Languages: Concepts and Implementation
book

Programming Languages: Concepts and Implementation

by Saverio Perugini
December 2021
Beginner
840 pages
47h 29m
English
Jones & Bartlett Learning
Content preview from Programming Languages: Concepts and Implementation

B.8 User-Defined Functions

A key language concept in ML is that all functions have types.

B.8.1 Simple User-Defined Functions

Named functions are introduced with fun:

A set of four code lines in M L with simple user-defined functions.
Description

Here, the type of square is a function int -> int or, in other words, a function that maps an int to an int. Similarly, the type of add is a function int * int -> int or, in other words, a function that maps a tuple of type int * int to an int. Notice that the interpreter prints the domain of a function that accepts more than one parameter as a Cartesian product using the notation described in Section B.7. These functions are the ML analogs of the following Scheme ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Concepts and Semantics of Programming Languages 1

Concepts and Semantics of Programming Languages 1

Therese Hardin, Mathieu Jaume, Francois Pessaux, Veronique Viguie Donzeau-Gouge
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9781284222739