Skip to content

Instantly share code, notes, and snippets.

@multidis
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multidis/9988686 to your computer and use it in GitHub Desktop.
Save multidis/9988686 to your computer and use it in GitHub Desktop.
Julia language basic elements and aspects to keep in mind (from a MATLAB and R user perspective).
# mutating functions (modify arguments passed to them): end with ! (e.g. push! below)
# arguments are passed by reference
# just as e.g. mutable lists in Python, arrays are assigned by reference
# CAUTION here as in Python
A = zeros(2,3);
B = A;
# to avoid that use copying as in Python
C = A[:,:];
A[2,3] = 5;
B # modified since B references the same object
C # separate object, unmodified
# push! to append elements
q=[1;2];
push!(q,3) # q has been changed
# comprehensions
[ x[i]+x[i+1] for i=1:9 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment