Julia for Scienti c Programming
Julia for Scientific Programming
Seminar 2
Marcus Thelander Andr?en & Mattias F?alt
Dept. of Automatic Control Lund University
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Today's Goal
1 Scope and modules (briefly) 2 Handling objects
Types Methods Constructors Conversion Promotion 3 Iteration and iterable collections
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Discussion of previous assignment
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Scope of Variables
Where a variable name is visible in the code
Constructs introducing scope block: function bodies while loops for loops try blocks catch blocks let blocks type blocks
Note: begin and if blocks don't introduce scope blocks
When a variable is introduced into a scope, it is also inherited by all inner scopes unless one of those inner scopes explicitly overrides it.
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Scope of Variables
Function scope inherits variables from where the function was defined and NOT where it was called (lexical scoping ) Example:
function foo() x
end
function bar() x=1 foo ()
end
x=2
julia > bar() 2
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Modules
Separate global variable workspaces Syntax: module Name ... end
Use names from other modules with import, importall and using Specify which names are public with export
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Modules
Example: module MyModule export x, y x() = "x" y() = "y" p() = "p" end
x and y exported, not p
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
Modules
Different ways to load MyModule: using MyModule x,y, MyModule.x, MyModule.y and MyModule.p import MyModule MyModule.x, MyModule.y and MyModule.p importall MyModules x and y
Marcus Thelander Andr?en & Mattias F?alt
Julia for Scientific ProgrammingSeminar 2
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- the julia express
- erik engheim accu
- numpy user guide scipy
- floating point typedefs having specified widths n1703
- numerical computing in python cornell university
- erik engheim
- an introduction to numpy and scipy ucsb college of engineering
- cs 649 intro to big data tools and methods spring semester 2022 doc
- package int64 universidad autónoma del estado de morelos
- just in time compilation washington state university
Related searches
- c programming language standard
- c programming language specification
- c programming int to string
- c programming books pdf
- c programming book pdf download
- c programming textbook pdf
- c programming for beginners pdf
- c programming string array
- c programming array examples
- c programming linked list
- c programming char array initialization
- c programming character array