[julia-users] Re: if-elseif-else programmatically

2016-09-24 Thread Fengyang Wang
Oh yeah, or x[direction] += rand(-1:2:1) to avoid the need for the allocation in the first place. On Sunday, September 25, 2016 at 1:01:47 AM UTC-4, Fengyang Wang wrote: > > You could even do x[direction] += rand([-1, 1]). The allocation can be > avoided by defining a global constant with [-1,

[julia-users] Re: if-elseif-else programmatically

2016-09-24 Thread Fengyang Wang
You could even do x[direction] += rand([-1, 1]). The allocation can be avoided by defining a global constant with [-1, 1] as its contents. On Saturday, September 24, 2016 at 6:54:47 PM UTC-4, Steven G. Johnson wrote: > > > > On Saturday, September 24, 2016 at 6:09:14 PM UTC-4, David P. Sanders

[julia-users] Re: How to update a precompiled Module's data from a second module?

2016-09-24 Thread Philip Tellis
Ok, just discovered that I should put my code from External into `__init__()` to get it to run at compile time

[julia-users] How to update a precompiled Module's data from a second module?

2016-09-24 Thread Philip Tellis
I have two modules that are included by a julia program. Let's call them Primary and External. Primary contains a list of names in an array that's global to the module and a method to register new names: module Primary global names = AbstractString[] function

[julia-users] Re: PkgDev.tag issues

2016-09-24 Thread Tony Kelman
You may have to remove the git tag from your local clone of the package repo.

[julia-users] Re: Broadcast slices

2016-09-24 Thread Brandon Taylor
Or I guess that should be broadcast_slices(best_response_dimension, player_dimension, payoff_matrix, players) On Saturday, September 24, 2016 at 9:38:55 PM UTC-4, Brandon Taylor wrote: > > I guess, but I'm trying to write a generic program where I don't know the > size of the array? I'm trying

[julia-users] Re: Broadcast slices

2016-09-24 Thread Brandon Taylor
I guess, but I'm trying to write a generic program where I don't know the size of the array? I'm trying to find Nash Equilibrium for an n dimensional array, where the player strategies are along dimensions 1:n-1, and the players are along dimension n. So: equals_max(x) = x .== maximum(x)

[julia-users] Re: Get the red out!

2016-09-24 Thread Simon Danisch
How about something like this: function showtypetree(T, level=0) println("\t" ^ level, T) for t in subtypes(T) (t != Any) && showtypetree(t, level+1) end end This is still not type stable, since *_subtype *seems to use untyped sets:

[julia-users] Re: if-elseif-else programmatically

2016-09-24 Thread Steven G. Johnson
On Saturday, September 24, 2016 at 6:09:14 PM UTC-4, David P. Sanders wrote: > > julia> if rand() < 0.5 > You can also do "if rand(Bool)"

[julia-users] Get the red out!

2016-09-24 Thread Brian Rogoff
... of @code_warntype output. I was reading https://en.wikibooks.org/wiki/Introducing_Julia/Types#Investigating_types and I came across the following code, described as "not very elegant": level = 0 function showtypetree(subtype) global level subtypelist = filter(asubtype -> asubtype

[julia-users] Re: if-elseif-else programmatically

2016-09-24 Thread David P. Sanders
El sábado, 24 de septiembre de 2016, 21:26:52 (UTC+2), lapeyre@gmail.com escribió: > > I want to generate something like an if-elseif-else construct or > switch-case programmatically. > > The use I have in mind is to write an expression for taking a step in a > random walk in n

[julia-users] if-elseif-else programmatically

2016-09-24 Thread lapeyre . math122a
I want to generate something like an if-elseif-else construct or switch-case programmatically. The use I have in mind is to write an expression for taking a step in a random walk in n dimensions, so I need 2*n branches. The solution I found is not very readable. I wonder if there is an easier

Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-24 Thread Steven G. Johnson
On Saturday, September 24, 2016 at 9:09:38 AM UTC-4, Michele Zaffalon wrote: > > Sorry for being slow: the input array rand(10) or the output array, the > square of each element of rand(10)? > > julia> (begin;println(t);t^2;end for t=1:10) > Base.Generator{UnitRange{Int64},##37#38}(#37,1:10)

Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
OK, I see. Thank you very much! On Saturday, September 24, 2016 at 11:11:41 AM UTC-5, Spencer Russell wrote: > > Take a look at the performance tips in the manual: > http://docs.julialang.org/en/release-0.5/manual/performance-tips/ > > One of the main things is to avoid accessing global

Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
OK, I see. Thank you very much! On Saturday, September 24, 2016 at 11:11:41 AM UTC-5, Spencer Russell wrote: > > Take a look at the performance tips in the manual: > http://docs.julialang.org/en/release-0.5/manual/performance-tips/ > > One of the main things is to avoid accessing global

[julia-users] Re: julia-i18n: Translators and reviewer needed!

2016-09-24 Thread Ismael Venegas Castelló
The Julia website is now officially also in Spanish, more languages are coming soon! * http://julialang.org There are still translations and reviews to do, if you are looking for a way to contribute to Julia, check the website internationalization project on Transifex: *

[julia-users] Re: PkgDev.tag issues

2016-09-24 Thread Evan Fields
I've had this problem as well so I'm eager to learn a solution. It was a while ago, but when this happened to me, git status in the metadata repo would show uncommitted changes. I think I had to reset metadata to a clean state, manually delete some tags in the package repository, and run the

Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Spencer Russell
Take a look at the performance tips in the manual: http://docs.julialang.org/en/release-0.5/manual/performance-tips/ One of the main things is to avoid accessing global variables, and everything declared at the top-level in the

[julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
Hi there, Could anybody tell me what's wrong with my for loop code below and how to improve it? I was surprised to see it performs worse than the vectorized operation. Thank you! ## Calculate the maximum number in vector x that is less or equal to 0.5 > ## Method 1 > x=rand(1) > @time

[julia-users] Re: LightXML Ubuntu 16.04 julia 0.4.5

2016-09-24 Thread Ján Adamčák
Thanks, after installing sudo apt-get install libxml2-dev is LightXML fully working. I have another question: Why this dependency didn't resolved automatically by Pkg.add("LightXML") ? Dňa sobota, 24. septembra 2016 15:07:37 UTC+2 Tony Kelman napísal(-a): > > You might need the -dev

Re: [julia-users] Generators vs Comprehensions, Type-stability?

2016-09-24 Thread Michele Zaffalon
On Fri, Sep 23, 2016 at 1:14 PM, Steven G. Johnson wrote: > > > On Friday, September 23, 2016 at 2:42:00 AM UTC-4, Michele Zaffalon wrote: >> >> On Fri, Sep 23, 2016 at 2:23 AM, Steven G. Johnson >> wrote: >>> >>> >>> We could use type inference on the

[julia-users] Re: LightXML Ubuntu 16.04 julia 0.4.5

2016-09-24 Thread Tony Kelman
You might need the -dev version to get a plain "libxml2.so" in addition to the version with an soname in it. I thought Julia should be able to find the soname versions too, but maybe not? On Saturday, September 24, 2016 at 5:34:12 AM UTC-7, Ján Adamčák wrote: > > I tried sudo apt-get install

[julia-users] Re: LightXML Ubuntu 16.04 julia 0.4.5

2016-09-24 Thread Ján Adamčák
I tried sudo apt-get install libxml2, but I got answer from ubuntu: libxml2 is already the newest version (2.9.3+dfsg 1-1ubuntu0.1). libxml2 is tagged as manually installed. But from julia I got same answer: ERROR: error compiling call: could not load library "libxml2" Dňa sobota, 24.

[julia-users] Re: LightXML Ubuntu 16.04 julia 0.4.5

2016-09-24 Thread Kaj Wiik
Try sudo apt install libxml2 On Saturday, September 24, 2016 at 12:52:46 PM UTC+3, Ján Adamčák wrote: > > Hi Guys, > > I tried use LightXML on Ubuntu 16.04, but I got an error: > > ERROR: error compiling call: could not load library "libxml2" > > Can You help me? > > Thanks. > > Log: > >

[julia-users] Re: How does promote_op work?

2016-09-24 Thread Steven G. Johnson
On Friday, September 23, 2016 at 6:15:25 PM UTC-4, Pablo Zubieta wrote: > > The problem is empty arrays, when the type cannot be inferred broadcast > uses the types of each element to build the array. When there are no > elements it doesn't know what type to choose. > (For the empty array

[julia-users] Re: Problems with Memoize in Julia 0.5.0

2016-09-24 Thread Avik Sengupta
>I would file an issue with Memoize.jl; I'm not sure why the package is limited to memoizing only a single method definition, but this seems like it would need to be fixed upstream. https://github.com/simonster/Memoize.jl/issues/5 This is probably due to the new functions changes in 0.5.

[julia-users] LightXML Ubuntu 16.04 julia 0.4.5

2016-09-24 Thread Ján Adamčák
Hi Guys, I tried use LightXML on Ubuntu 16.04, but I got an error: ERROR: error compiling call: could not load library "libxml2" Can You help me? Thanks. Log: _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_)| Documentation:

Re: [julia-users] Cookbook for Julia

2016-09-24 Thread Tamas Papp
In this specific instance, it is worse: searching for "julia cookbook" or "julia recipes" leads you to the work of Juila Child. "julia -child" etc is only marginally better, there are apperently many cookbook authors with the first name Julia. Searching within Wikibooks and similar (Github) works

Re: [julia-users] Cookbook for Julia

2016-09-24 Thread daycaster
They used to say that you could never have too much documentation (like some other things in life), but an important proviso is that it should be easy to find what you're really looking for. Searching for Julia programming information isn't always easy: the official documentation's search is

Re: [julia-users] Cookbook for Julia

2016-09-24 Thread Tamas Papp
I wonder if you are aware of https://github.com/svaksha/Julia.jl/blob/master/Resources.md#cookbooks and in particular https://en.wikibooks.org/wiki/Introducing_Julia (Also, Packt is coming out with a Julia Cookbook: https://www.packtpub.com/application-development/julia-cookbook ) It seems