Last active
August 29, 2015 13:58
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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