In [4]:
a,b,c = cos(0.2),log(10),abs(-5) # Asignación múltiple


Out[4]:
(0.9800665778412416, 2.302585092994046, 5)

In [7]:
? cos # Para conseguir ayuda sobre la función


search: cos cosh cosd cosc cospi acos acosh acosd const consume cross close

Out[7]:
cos(x)

Compute cosine of x, where x is in radians.


In [8]:
? Array


search: Array SubArray BitArray ConjArray DenseArray StridedArray

Out[8]:
Array{T}(dims)
Array{T,N}(dims)

Construct an uninitialized N-dimensional dense array with element type T, where N is determined from the length or number of dims. dims may be a tuple or a series of integer arguments corresponding to the lengths in each dimension. If the rank N is supplied explicitly as in Array{T,N}(dims), then it must match the length or number of dims.

Example

jldoctest
julia> A = Array{Float64, 2}(2, 2);

julia> ndims(A)
2

julia> eltype(A)
Float64

In [10]:
? size


search: size sizeof sizehint! Csize_t resize! filesize Cssize_t serialize

Out[10]:
size(A::AbstractArray, [dim...])

Returns a tuple containing the dimensions of A. Optionally you can specify the dimension(s) you want the length of, and get the length of that dimension, or a tuple of the lengths of dimensions you asked for.

jldoctest
julia> A = ones(2,3,4);

julia> size(A, 2)
3

julia> size(A,3,2)
(4, 3)

In [11]:
?sort


search: sort sort! sortrows sortperm sortcols sortperm! Cshort issorted

Out[11]:
sort(v; alg::Algorithm=defalg(v), lt=isless, by=identity, rev::Bool=false, order::Ordering=Forward)

Variant of sort! that returns a sorted copy of v leaving v itself unmodified.

Examples

jldoctest
julia> v = [3, 1, 2];

julia> sort(v)
3-element Array{Int64,1}:
 1
 2
 3

julia> v
3-element Array{Int64,1}:
 3
 1
 2
sort(A, dim::Integer; alg::Algorithm=DEFAULT_UNSTABLE, lt=isless, by=identity, rev::Bool=false, order::Ordering=Forward, initialized::Bool=false)

Sort a multidimensional array A along the given dimension. See sort! for a description of possible keyword arguments.

Examples

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

julia> sort(A, 1)
2×2 Array{Int64,2}:
 1  2
 4  3

julia> sort(A, 2)
2×2 Array{Int64,2}:
 3  4
 1  2

In [13]:
methods(sort) # Sirve para checar cuantos tipos de datos se aceptan.


Out[13]:
5 methods for generic function sort:

In [14]:
mifuncion(parametro) = 20*parametro # Para funciones de una sola linea.


Out[14]:
mifuncion (generic function with 1 method)

In [16]:
mifuncion(10.2)


Out[16]:
204.0
search: function Function functionloc cfunction @functionloc


In [18]:
#Para crear funciones con más de una linea de código
function nuevaFuncion(a,b,c)
    a*b+c
end


Out[18]:
nuevaFuncion (generic function with 1 method)

In [19]:
nuevaFuncion(1,2,3)


Out[19]:
5

In [10]:
function funcionPrueba(var)
    println("Hola $(typeof(var))")
end


Out[10]:
funcionPrueba (generic function with 1 method)

In [12]:
funcionPrueba(10)


Hola Int64
Prueba 10

In [13]:
α = ['a',2.]
funcionPrueba(α)


Hola Array{Any,1}
Prueba Any['a', 2.0]

In [14]:
? \


search: \ .\

Out[14]:
\(x, y)

Left division operator: multiplication of y by the inverse of x on the left. Gives floating-point results for integer arguments.

jldoctest
julia> 3 \ 6
2.0

julia> inv(3) * 6
2.0

julia> A = [1 2; 3 4]; x = [5, 6];

julia> A \ x
2-element Array{Float64,1}:
 -4.0
  4.5

julia> inv(A) * x
2-element Array{Float64,1}:
 -4.0
  4.5
\(A, B)

Matrix division using a polyalgorithm. For input matrices A and B, the result X is such that A*X == B when A is square. The solver that is used depends upon the structure of A. If A is upper or lower triangular (or diagonal), no factorization of A is required and the system is solved with either forward or backward substitution. For non-triangular square matrices, an LU factorization is used.

For rectangular A the result is the minimum-norm least squares solution computed by a pivoted QR factorization of A and a rank estimate of A based on the R factor.

When A is sparse, a similar polyalgorithm is used. For indefinite matrices, the LDLt factorization does not use pivoting during the numerical factorization and therefore the procedure can fail even for invertible matrices.

Example

jldoctest
julia> A = [1 0; 1 -2]; B = [32; -4];

julia> X = A \ B
2-element Array{Float64,1}:
 32.0
 18.0

julia> A * X == B
true

In [16]:
add2(x,y) = return x+y


Out[16]:
add2 (generic function with 1 method)

In [17]:
add2(1,2)


Out[17]:
3

In [18]:
function coordinates(x, y=0, z=0)
  println("($x, $y, $z)")
end


Out[18]:
coordinates (generic function with 3 methods)

In [19]:
coordinates(1,0)


(1, 0, 0)

In [20]:
function test(input)
  println("$input"^2)
end

test(2)


22

In [ ]: