Chapter 3. Functions

Julia is foremost a functional language because computations and data transformations are done through functions; they are first-class citizens in Julia. Programs are structured around defining functions and to overload them for different combinations of argument types. This chapter discusses this keystone concept, covering the following topics:

  • Defining functions
  • Optional and keyword arguments
  • Anonymous functions
  • First-class functions and closures
  • Recursive functions
  • Map, filter, and list comprehensions
  • Generic functions and multiple dispatch

Defining functions

A function is an object that gets a number of arguments (the argument list, arglist) as the input, then does something with these values in the function body, and returns none, ...

Get Getting Started with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.