Re: [julia-users] Re: How can I find the common elements of two matrix(or arrays)?

2016-07-21 Thread Joshua Ballanco
Use `enumerate`: julia> a = [1,3,5,8] julia> b = [1,2,5,7] julia> intersect(enumerate(a), enumerate(b)) 2-element Array{Tuple{Int64,Int64},1}: (1,1) (3,5) On July 5, 2016 at 13:20:15, siyu song (siyuphs...@gmail.com) wrote: Good to know this method. Thanks a lot. 在 2016年7月6日星期三

Re: [julia-users] parsing error?

2016-05-22 Thread Joshua Ballanco
Hi Davide, Looks like an issue of operator precedence:  http://docs.julialang.org/en/release-0.4/manual/mathematical-operations/#operator-precedence That is, since `\` is higher precedence than `:`, your initial line is being parsed as `(randn(3, 3)\1):3`, so the error seems to be correct.

Re: [julia-users] Weird Hygiene Issue

2016-02-15 Thread Joshua Ballanco
On February 15, 2016 at 17:15:26, Lutfullah Tomak (tomaklu...@gmail.com(mailto:tomaklu...@gmail.com)) wrote: > Shouldn't it be if you escaped > > julia> module X > macro p(y) > esc(quote > println($y) > end) > end > macro q(y) > quote > println(:($($y))) > end > end > end > X > > julia>

Re: [julia-users] Weird Hygiene Issue

2016-02-15 Thread Joshua Ballanco
On February 14, 2016 at 21:49:30, Julia Tylors (juliatyl...@gmail.com(mailto:juliatyl...@gmail.com)) wrote: > Hi fellows, > > > I was coding a macro, and I am having a prefix issue with functions. > > basically the problem is: Every single one of available functions (_ex_func) > which

Re: [julia-users] Re: Nullable{Date}

2016-02-10 Thread Joshua Ballanco
The problem is not so much when you are (potentially) generating and handling null dates in your own code, but how one interacts with library code that may or may not return a null. Especially in a dynamically typed language, in the absence of a Nullable type the only way to determine if a

Re: [julia-users] Julia vs Clojure for Distributed Scientific Simulations

2016-01-27 Thread Joshua Ballanco
Last I checked, I think the only real option for calling Julia from Java is via JNA to the Julia C API. Not impossible, but not as convenient as JavaCall.jl. As for Julia vs Clojure, I had a go at implementing a simple OCR nearest-neighbors algorithm in both Julia and Clojure. The Clojure code

Re: [julia-users] Re: Requests.jl with HTTP Basic Authentication

2016-01-26 Thread Joshua Ballanco
On January 26, 2016 at 15:42:11, Josef Sachs (sa...@cyb.org(mailto:sa...@cyb.org)) wrote: > Here is the URL that I tried to post, with the parts on separate lines. > https: > // > user > : > pass/word > @ > google.com > > I was trying to demonstrate a password with a slash in it. > The @

Re: [julia-users] Immutable type with a function datatype

2016-01-18 Thread Joshua Ballanco
On January 18, 2016 at 17:08:46, Anonymous (espr...@gmail.com) wrote: This mimics the behavior of OOP since just like in OOP the internal method cannot be changed (since the type is immutable).  Sometimes it really does make the most sense to attach a function to an instance of a type... I

Re: [julia-users] Defining function's argument to be either Int or Float

2016-01-11 Thread Joshua Ballanco
I don’t have any pointers to Julia-specific discussion, but this paper from the Kotlin project is rather enlightening on the subject:  http://www.cs.cornell.edu/~ross/publications/mixedsite/ . In particular, Kotlin has come up with a rather clever solution to the co-/contra-variance mess from

Re: [julia-users] Julia garbage collection - question on status and future (and interaction when using with other languages)

2015-10-23 Thread Joshua Ballanco
Just to throw this out there… A number of years ago Mike Pall (creator and former maintainer of LuaJIT) outlined the beginnings of what seemed (to me at least) to be a very interesting variation on the tricolor GC: http://wiki.luajit.org/New-Garbage-Collector . Originally this was intended for

Re: [julia-users] Re: IDE for Julia

2015-09-14 Thread Joshua Ballanco
  On September 14, 2015 at 14:17:43, Daniel Carrera (dcarr...@gmail.com(mailto:dcarr...@gmail.com)) wrote: > On 14 September 2015 at 12:40, J Luis wrote: > > > > > > segunda-feira, 14 de Setembro de 2015 às 09:26:05 UTC+1, Daniel Carrera > > escreveu: > > > > > > On 14 September 2015 at

Re: [julia-users] Adding backslashes to a string fails

2015-09-08 Thread Joshua Ballanco
I think you’re just seeing the REPL printing the String object, which represents backslashes as escaped. Printing the result should clarify things: julia> replace("my_beautiful_string", "_", "\\_") "my\\_beautiful\\_string" julia> println(replace("my_beautiful_string", "_", "\\_"))

Re: [julia-users] Define functions in loop

2015-09-03 Thread Joshua Ballanco
Out of curiosity, why use `@eval` directly instead of defining a macro? (I’m just trying to get a better feel for what’s more Julian.) On September 2, 2015 at 12:44:39, Patrick Kofod Mogensen (patrick.mogen...@gmail.com) wrote: I'm in a train right now, but yes. Look up metaprogramming in the

Re: [julia-users] Define functions in loop

2015-09-03 Thread Joshua Ballanco
Ok, makes sense. For what it’s worth (I’m very new at Julia, but have been using Lisp/Scheme/Clojure for a while now)… In Lisp/Clojure I think there’s a preference even for internal function definitions to use macros vs eval for the reason that macros modify the source at parse time, but eval

Re: [julia-users] Type promotion bug?

2015-08-27 Thread Joshua Ballanco
On August 26, 2015 at 21:30:47, Yichao Yu (yyc1...@gmail.com(mailto:yyc1...@gmail.com)) wrote: On Wed, Aug 26, 2015 at 12:44 PM, Sisyphuss wrote: Of course, I know how to write the valid code. But in the interactive environment, if someone accidentally defines the promote_rule in the

[julia-users] Types and the Liskov Substitution Principle

2015-08-23 Thread Joshua Ballanco
Hello all, Apologies in advance if I’m missing something obvious. I’ve only just started experimenting with some of the more advanced features of Julia’s types, and I’ve hit a bit of a wall… Say I wanted to replicate something like Python’s `collections.defaultdict` or Ruby’s `Hash` class

Re: [julia-users] Re: Types and the Liskov Substitution Principle

2015-08-23 Thread Joshua Ballanco
missing: 1) You should define outer constructor for `DefaultDict(val, Dict())`; 2) You should make your promotion rules parametric. On Sunday, August 23, 2015 at 7:48:11 PM UTC+2, Joshua Ballanco wrote: Hello all, Apologies in advance if I’m missing something obvious. I’ve only just started

Re: [julia-users] Types and the Liskov Substitution Principle

2015-08-23 Thread Joshua Ballanco
On August 23, 2015 at 21:08:16, Kevin Squire (kevin.squ...@gmail.com) wrote: If the type hierarchy is implemented well, functions for `Dict` would ideally be written to work with `super(Dict)` (i.e., `Associative`).  And in fact, some are--e.g., `in`, `haskey`, `show`, `keys`, `values`, etc.