[julia-users] Best practice to type-check for array of floats?

2014-08-15 Thread Brendan O'Connor
Hi, What's the best way to typecheck that an array is of floats, but any precision is OK? I've found it useful to do this because a number of operations fail when given integer vector inputs (for example, 10.^[-3:3]). I noticed that x::Vector{FloatingPoint} does not seem to cover them. I

Re: [julia-users] Best practice to type-check for array of floats?

2014-08-15 Thread Brendan O'Connor
On Fri, Aug 15, 2014 at 9:53 PM, John Myles White johnmyleswh...@gmail.com wrote: Hi Brendan, It looks like you’re hitting Julia’s invariance for the first time: http://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science) Oh nice. I could never keep the

Re: [julia-users] Create matrix from a comprehension with row/col-returning function?

2014-08-14 Thread Brendan O'Connor
hcat and vcat will do the trick. Thanks! -Brendan

[julia-users] Create matrix from a comprehension with row/col-returning function?

2014-08-13 Thread Brendan O'Connor
Hi, I'd like to create a matrix with an array comprehension. Specifically, I have a function that returns a 2-length array, like function f() [3.0, 5.0] end And I'd like an Nx2 (or 2xN) matrix from its output. Unfortunately, an obvious way of calling it results in: [f() for i=1:3]

Re: [julia-users] Create matrix from a comprehension with row/col-returning function?

2014-08-13 Thread Brendan O'Connor
But that calls `f()` on every loop of your comprehension, so it's probably best to do something like: g = f() In [13]: [g[i] for i=1:2, j=1:3] Out [13]: 2x3 Array{Any,2}: 3.0 3.0 3.0 5.0 5.0 5.0 Ah ... I should have said, actually, I don't want a constant value. I wanted f()

Re: [julia-users] Re: Style Guideline

2014-01-01 Thread Brendan O'Connor
On Tuesday, December 31, 2013 2:05:06 PM UTC-5, John Myles White wrote: (7) + (8) These rules are part of the official Google style guides for R, which is the language with the most similarity to Julia that’s being used at companies with public facing style guidelines. I think they’re quite