Skip to content
  • YouTube
  • FaceBook
  • Twitter
  • Instagram

Data Analytics Ireland

Data Analytics and Video Tutorials

  • Home
  • Contact
  • About Us
    • Latest
    • Write for us
    • Learn more information about our website
  • Useful Links
  • Glossary
  • All Categories
  • Faq
  • Livestream
  • Toggle search form
  • Regular expressions python Python
  • What is Jupyter notebook? Jupyter Notebook
  • Python Tutorial: How to sort lists Python Lists
  • What are dimensions in Tableau? data visualisation
  • How To Check For Unwanted Characters Using Loops With Python Python Data Cleansing
  • How To Pass Data Between Functions Python Functions
  • How to show percentage differences between files in Python CSV
  • python constructor self and __init__explained Python

What does the … operator do in Julia?

Posted on March 28, 2023March 28, 2023 By admin

Estimated reading time: 2 minutes

In Julia, the ... operator, also known as the “splat” or “ellipsis” operator, is used to unpack the contents of a collection or tuple.

Here are a few common use cases:

  1. Function arguments: When used in a function call, the ... operator can be used to pass the elements of a collection or tuple as separate arguments to the function.

In the example below, we create our Tuple and then call it in the function which then prints it out.

julia> function my_function(x, y, z)
           print(x,y,z)
       end
my_function (generic function with 1 method)


julia> my_tuple = (1, 2, 3)
(1, 2, 3)

julia> my_function(my_tuple...)
123

2. Function definitions: The ... operator can be used in function definitions to allow for a variable number of arguments.

As a result, in this example, the my_function gets passed five variables.

As you can see there are three … at the end of the function. What this does is then instructs the print function to print the last three integers passed inside the bracket, and leave the first two outside.

The reason for this is that the print statement prints the first two parameters passed, then as z has … after it, splits the 3rd and subsequent parameters into a Tuple.

julia> function my_function(x, y, z...)
           print(x,y,z)
       end
my_function (generic function with 2 methods)

julia>my_function(1, 2, 3)
12(3, 4, 5)

3. Tuple construction: The ... operator can be used to concatenate two or more tuples into a single tuple. For example:

julia> tuple1 = (1, 2)
(1, 2)

julia> tuple2 = (3, 4)
(3, 4)

julia> tuple3 = (5, 6)
(5, 6)


julia> tuple4 = (tuple1..., tuple2..., tuple3...)
(1, 2, 3, 4, 5, 6)

4. Array construction: The ... operator can be used to concatenate two or more arrays along a specified dimension. For example:

julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> B = [5 6; 7 8]
2×2 Matrix{Int64}:
 5  6
 7  8

julia> C = [A B] # horizontal concatenation
2×4 Matrix{Int64}:
 1  2  5  6
 3  4  7  8

julia> D = [A; B] # vertical concatenation
4×2 Matrix{Int64}:
 1  2
 3  4
 5  6
 7  8

Note that the ... operator can also be used in other contexts, such as in variable assignments, but its primary purpose is for unpacking and concatenation.

julia, Julia programming Tags:julia, julia programming

Post navigation

Previous Post: What are bitwise operators in Julia?
Next Post: What are anonymous functions in Julia?

Related Posts

  • What is Julia used for? Julia programming
  • What are bitwise operators in Julia? julia
  • How can packages be managed in Julia? Julia programming
  • What are the built-in exceptions in Julia? Julia programming
  • Why choose Julia over other programming languages? Julia programming
  • What are anonymous functions in Julia? array

Select your language!

  • English
  • हिंदी
  • Español
  • Português
  • Français
  • Italiano
  • how to select columns with SQL SQL
  • What does a data analyst do? Livestream
  • TypeError: Array() Argument 1 Must Be A Unicode Character, Not List array
  • how to select all records with SQL SQL
  • TypeError: List Indices Must Be Integers Or Slices, Not Tuple exceptions
  • What is Query Optimization in SQL? SQL
  • how to build a machine learning model machine learning
  • how to create and drop a table in SQL SQL

Copyright © 2023 Data Analytics Ireland.

Powered by PressBook Premium theme

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT