Merge branch 'master' of https://github.com/EddieCueto/trying_julia
[MOD] to use old files
This commit is contained in:
commit
f3c835d7c2
|
@ -0,0 +1,49 @@
|
|||
println(typeof(3))
|
||||
|
||||
telltype(x) = "Unknown type"
|
||||
|
||||
println(telltype(2))
|
||||
|
||||
telltype(x::Integer) = "Integer type"
|
||||
|
||||
telltype(::AbstractFloat) = "Floatingpoint type"
|
||||
|
||||
println(telltype("a"))
|
||||
|
||||
println(telltype(2))
|
||||
|
||||
println(telltype(2.0))
|
||||
|
||||
telltype(::Int64) = "64 bit integer"
|
||||
|
||||
println(telltype(1))
|
||||
|
||||
countargs(a) = "one"
|
||||
|
||||
countargs(a,b) = "two"
|
||||
|
||||
countargs(a,b,c) = "three"
|
||||
|
||||
println(countargs(1))
|
||||
|
||||
println(countargs(1,2))
|
||||
|
||||
println(countargs(1,2,3))
|
||||
|
||||
println(countargs("abc",2))
|
||||
|
||||
foo(a,b) = "Two variables"
|
||||
|
||||
foo(a::Integer,b::Integer) = "Two integers"
|
||||
|
||||
foo(a::Integer,b::AbstractFloat) = "An integer and a float"
|
||||
|
||||
foo(a::AbstractFloat,b::Integer) = "A float and a integer"
|
||||
|
||||
println(foo('a',1))
|
||||
|
||||
println(foo(2,1))
|
||||
|
||||
println(foo(2.0,1))
|
||||
|
||||
println(foo(2,1.1))
|
|
@ -0,0 +1,61 @@
|
|||
function foobar(a,b)
|
||||
x::Int8 = a
|
||||
y::Int8 = b
|
||||
return x+y
|
||||
end
|
||||
|
||||
println(foobar(1,2))
|
||||
|
||||
println(typeof(foobar(1,2)))
|
||||
|
||||
#println(foobar("1","2"))
|
||||
|
||||
println(Int8(4))
|
||||
|
||||
#println(Int8("4"))
|
||||
|
||||
println(isa(2,Int64))
|
||||
|
||||
println(isa(2,Float64))
|
||||
|
||||
println(isa(2,Integer))
|
||||
|
||||
println(isa(Int8,DataType))
|
||||
|
||||
println(isa(Int8,Type{Int8}))
|
||||
|
||||
println(isa(Int8,Type{Int16}))
|
||||
|
||||
println(convert(Int8,4))
|
||||
|
||||
println(typeof(convert(Int8,4)))
|
||||
|
||||
# convert(::Type{Int8}, x::Int64) =
|
||||
|
||||
Base.convert(::Type{Int8}, x::String) = parse(Int8,x)
|
||||
|
||||
println(foobar("1","2"))
|
||||
|
||||
println(Int8("4"))
|
||||
|
||||
println(1+2.0+Int8(3))
|
||||
|
||||
println(typeof(1+2.0+Int8(3)))
|
||||
|
||||
println(promote(1,2.0,Int8(3)))
|
||||
|
||||
a = promote(1,2.0,Int8(3))
|
||||
|
||||
println(+(a...)) # ... tuple unpacker
|
||||
|
||||
b = (3,2)
|
||||
|
||||
println(+(b...))
|
||||
|
||||
println(promote(Int8(2),Int16(4)))
|
||||
|
||||
c = promote(Int8(2),Int16(4))
|
||||
|
||||
println(typeof(c))
|
||||
|
||||
@edit 2+4
|
Loading…
Reference in New Issue