In [ ]:
julia> x = 3
3
julia> f(x) = x[1]=10
f (generic function with 1 method)
julia> f(x)
ERROR: `setindex!` has no method matching setindex!(::Int64, ::Int64, ::Int64)
in f at none:1
julia> x
3
julia> x
3
julia> x[1]
3
julia>
~
15:17 $ clear
~
15:17 $ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.6-pre+43 (2015-01-22 20:39 UTC)
_/ |\__'_|_|_|\__'_| | Commit 2dfde6b* (21 days old release-0.3)
|__/ | x86_64-apple-darwin14.0.0
julia> function f(x)
x = 10
end
f (generic function with 1 method)
julia> y = 3
3
julia> f(y)
10
julia> y
3
julia> function g(x)
x[1] = 10
end
g (generic function with 1 method)
julia> v = [3, 4, 5]
3-element Array{Int64,1}:
3
4
5
julia> g(v)
10
julia> v
3-element Array{Int64,1}:
10
4
5
julia> function h(x)
x = [3, 4, 5]
end
h (generic function with 1 method)
julia> h(v)
3-element Array{Int64,1}:
3
4
5
julia> v
3-element Array{Int64,1}:
10
4
5
julia> ^C
julia>
julia> f(x)
ERROR: x not defined
julia> function f(x)
global hola
hola = 100
end
f (generic function with 1 method)
julia> hola =3
3
julia> f(10)
100
julia> hola
100
julia> f(x::Int) = 3x
f (generic function with 2 methods)
julia> duplicar(x::Int) = 2x
duplicar (generic function with 1 method)
julia> duplicar(2)
4
julia> duplicar(2.5)
ERROR: `duplicar` has no method matching duplicar(::Float64)
julia> duplicar(x) = 2x
duplicar (generic function with 2 methods)
julia> duplicar(2.5)
5.0
julia> duplicar(2+im)
4 + 2im
julia> abs(-3)
3
julia> abs(-3.5)
3.5
julia> abs(1+2im)
2.23606797749979
julia> sqrt(5)
2.23606797749979
julia> methods(abs)
# 19 methods for generic function "abs":
abs(x::Bool) at bool.jl:28
abs(x::Unsigned) at int.jl:74
abs(x::Signed) at int.jl:75
abs(x::Float64) at float.jl:207
abs(x::Float32) at float.jl:208
abs(x::Float16) at float16.jl:130
abs(x::Real) at number.jl:24
abs(z::Complex{T<:Real}) at complex.jl:103
abs(B::BitArray{N}) at bitarray.jl:783
abs(A::SparseMatrixCSC{Tv,Ti<:Integer}) at sparse/sparsematrix.jl:481
abs(f::Array{FieldValue,1}) at pkg/resolve/fieldvalue.jl:62
abs{T<:Number}(::AbstractArray{T<:Number,1}) at operators.jl:359
abs{T<:Number}(::AbstractArray{T<:Number,2}) at operators.jl:360
abs{T<:Number}(::AbstractArray{T<:Number,N}) at operators.jl:362
abs{T}(a::HierarchicalValue{T}) at pkg/resolve/versionweight.jl:66
abs(a::VWPreBuildItem) at pkg/resolve/versionweight.jl:94
abs(a::VWPreBuild) at pkg/resolve/versionweight.jl:131
abs(a::VersionWeight) at pkg/resolve/versionweight.jl:185
abs(a::FieldValue) at pkg/resolve/fieldvalue.jl:61
julia> duplicar("s")
ERROR: `*` has no method matching *(::Int64, ::ASCIIString)
in duplicar at none:1
julia> duplicar(s::String) == string(s, s)
ERROR: s not defined
julia> duplicar(s::String) = string(s, s)
duplicar (generic function with 3 methods)
julia> duplicar("Hola")
"HolaHola"
julia> duplicar(s::String) = s*s
duplicar (generic function with 3 methods)
julia> duplicar("Hola")
"HolaHola"
julia> s = "David"
"David"
julia> s + s
ERROR: `+` has no method matching +(::ASCIIString, ::ASCIIString)
julia> +(s1::String, s2::String) = s1*s2
+ (generic function with 118 methods)
julia> s + s
"DavidDavid"
julia> s1::String + s2::String = s1*s2
+ (generic function with 118 methods)