[julia-users] Composition of setindex!

2016-08-20 Thread Po Choi
julia> a = zeros(5) 5-element Array{Float64,1}: 0.0 0.0 0.0 0.0 0.0 julia> a[1:3][1:2] = 1.0 1.0 julia> a 5-element Array{Float64,1}: 0.0 0.0 0.0 0.0 0.0 I understand that `a[1:3]` creates an extra array and then `a[1:3][1:2] = 1.0` modified the extra array rather than the origin `a`

[julia-users] Any suggested mono font for julia with unicode?

2016-07-12 Thread Po Choi
I find that some mono fonts doesn't display distinguishable greek letters in unicode. Any suggested mono font for julia with unicode?

[julia-users] Abstract type and parametric type in multiple dispatch

2016-06-14 Thread Po Choi
julia> abstract Human julia> immutable Man <: Human x::ASCIIString end julia> julia> john = Man("John") Man("John") julia> function yo(h::Human) println("yo ", h.x) end yo (generic function with 1 method) julia> yo(john) yo John julia> function yo{T <: Human}(h

Re: [julia-users] Re: Does it make sense to loop over types?

2016-06-10 Thread Po Choi
equires a hash table lookup at > run time, and likely some memory allocation. > > -erik > > > On Fri, Jun 10, 2016 at 9:40 PM, Po Choi > wrote: > >> Ops! I accidentally hit the post button! So the post is not completed! >> >> It is an example: >>

[julia-users] Re: Does it make sense to loop over types?

2016-06-10 Thread Po Choi
still trying to understand how the multiple-dispatch works. Sometimes I am confused! On Friday, June 10, 2016 at 6:37:31 PM UTC-7, Po Choi wrote: > > > > foo(::Val{1}) = 1 > foo(::Val{2}) = 2 > foo(::Val{2}) = 3 > > function bar() > > for t in Datatype[Val{k} for k in 1:3] > > end > end > > > > > > > > > > >

[julia-users] Does it make sense to loop over types?

2016-06-10 Thread Po Choi
foo(::Val{1}) = 1 foo(::Val{2}) = 2 foo(::Val{2}) = 3 function bar() for t in Datatype[Val{k} for k in 1:3] end end

[julia-users] Fun Fact: Julia is space sensitive (in some sense)

2016-05-24 Thread Po Choi
julia> a = zeros(3) 3-element Array{Float64,1}: 0.0 0.0 0.0 julia> a[2+1] 0.0 julia> a[2 + 1] 0.0 julia> a[2+ 1] 0.0 julia> a[2 +1] ERROR: MethodError: `typed_hcat` has no method matching typed_hcat(::Array{Float64,1}, ::Int64, ::Int64) Closest candidates are: typed_hcat(::Type{T}, ::Nu

Re: [julia-users] In these two ways to "create functions", which one is a better way?

2016-04-20 Thread Po Choi
Thanks. I need to pass a set of orthogonal functions and coefficients into my routines. So I want to know the best practice in Julia to do this. On Wednesday, April 20, 2016 at 12:51:47 AM UTC-7, David P. Sanders wrote: > > If this is your actual use case, then I suggest checking out the > Polyn

Re: [julia-users] In these two ways to "create functions", which one is a better way?

2016-04-19 Thread Po Choi
t; On Tue, Apr 19, 2016 at 11:31 PM, Po Choi > wrote: > > Given coefficients, say, coeff = [1,2,3] > > I want to get a function for the polynomial: f(x) = coeff[1] * x + > coeff[1] > > * x^2 + coeff[1] * x^3 > > > > First way > > create_function(c

[julia-users] In these two ways to "create functions", which one is a better way?

2016-04-19 Thread Po Choi
Given coefficients, say, coeff = [1,2,3] I want to get a function for the polynomial: f(x) = coeff[1] * x + coeff[1] * x^2 + coeff[1] * x^3 First way create_function(coeff) = x -> sum(coeff .* [x^k for k in 1:length(coeff)]) Second way immutable Myfunction coeff::Vector end call(f::Myfuncti

Re: [julia-users] What is the correct way to use the type alias Vector and Matrix in multiple dispatch?

2016-04-07 Thread Po Choi
K the only way to make a generic function is to > introduce type parameters (using either Array{T,2} or Matrix{T} should be > fully equivalent). > > Does that help? > Andy > > > On Thursday, April 7, 2016 at 9:58:50 AM UTC+10, Po Choi wrote: >> >> >> Does

Re: [julia-users] What is the correct way to use the type alias Vector and Matrix in multiple dispatch?

2016-04-06 Thread Po Choi
a little bit confused about the `T`. Why can `T` appear inside `AAA` without being declared? On Wednesday, April 6, 2016 at 1:44:38 PM UTC-7, Yichao Yu wrote: > > On Wed, Apr 6, 2016 at 4:23 PM, Po Choi > > wrote: > > > > hello(A::Matrix) = 1 > > hello(A::Vector{M

[julia-users] What is the correct way to use the type alias Vector and Matrix in multiple dispatch?

2016-04-06 Thread Po Choi
hello(A::Matrix) = 1 hello(A::Vector{Matrix}) = 2 A = randn(3,3); AA = [randn(3,3) for k in 1:4]; hello(A) hello(AA) The output has method error. julia> hello(A) 1 julia> hello(AA) ERROR: MethodError: `hello` has no method matching hello(::Array{Array{Float64,2},1}) If I write down the types

[julia-users] Re: ANN: A potential new Discourse-based Julia forum

2016-02-23 Thread Po Choi
Does it support MathJax? On Saturday, September 19, 2015 at 5:16:36 PM UTC-7, Jonathan Malmaud wrote: > > Hi all, > There's been some chatter about maybe switching to a new, more modern > forum platform for Julia that could potentially subsume julia-users, > julia-dev, julia-stats, julia-gpu, an

[julia-users] How to do multiple dispatch on different dimension of matrices?

2016-02-12 Thread Po Choi
Can I do something like this? testMatrix(x::Array{1}) = println("It is 1-dimensional.") testMatrix(x::Array{2}) = println("It is 2-dimensional.") The above does not work because Array{1} == Array{1, N} One solution is testMatrixAgain{T}(x::Array{T, 1}) = println("It is 1-dimensional.") testMatrix

Re: [julia-users] Re: documentation suggestions

2016-02-12 Thread Po Choi
Before seriously hiring someone to bring Julia into your school, perhaps you first can try the commercial service from http://juliacomputing.com/ to organize some workshops or events to see how the students and other faculties feel about the potential of Julia. On Wednesday, February 10, 2016 a

Re: [julia-users] Re: Googling the functions I need in Julia is hard

2016-02-12 Thread Po Choi
Good point. I tried to use this search box in Juila manual, but get nothing. In R and Matlab, the search would return the function sd/std. I think, not only the "words" in Julia documentation is needed to improved, but also the search engine. On Friday, February 12, 2016 at 12:52:19 AM UTC-8, Mi

[julia-users] Googling the functions I need in Julia is hard

2016-02-11 Thread Po Choi
One thing I hate Julia is that it is very hard to google for the functions I need. I feel like Julia has no documentation. If I google "R standard deviation", the first link is https://stat.ethz.ch/R-manual/R-devel/library/stats/html/sd.html which tells all the things about the standard deviation