Book Image

Julia Cookbook

By : Raj R Jalem, Jalem Raj Rohit
Book Image

Julia Cookbook

By: Raj R Jalem, Jalem Raj Rohit

Overview of this book

Want to handle everything that Julia can throw at you and get the most of it every day? This practical guide to programming with Julia for performing numerical computation will make you more productive and able work with data more efficiently. The book starts with the main features of Julia to help you quickly refresh your knowledge of functions, modules, and arrays. We’ll also show you how to utilize the Julia language to identify, retrieve, and transform data sets so you can perform data analysis and data manipulation. Later on, you’ll see how to optimize data science programs with parallel computing and memory allocation. You’ll get familiar with the concepts of package development and networking to solve numerical problems using the Julia platform. This book includes recipes on identifying and classifying data science problems, data modelling, data analysis, data manipulation, meta-programming, multidimensional arrays, and parallel computing. By the end of the book, you will acquire the skills to work more effectively with your data.
Table of Contents (12 chapters)

The Eval function


The eval() function is simply used for executing or evaluating an Expression object. The evaluations and executions are done in a global scope.

Getting ready

To get started with this section, you must simply have your Julia REPL up and running.

How to do it...

Let's work on some examples to understand the eval() function better.

Construct an expression for adding two variables:

  1. First define the variable:

    p = 2
    q = 3
    

    The output would look like this:

  2. Now, construct the expression:

    exp = :(p + q)
    

  3. Now, check the value of the expression with the eval() function:

    eval(exp)
    

Now, let's look at functions that take in one or more Expression objects as input arguments and return another Expression object as the output. Let's understand this better through an example:

  1. The following code creates a function that we discussed in the preceding example, one which takes in expressions as inputs and also return expressions as outputs:

    function example_exp(op, var1, var2)
    exp = Expr(:call, op...