Hi, just a quick question on the scope/environment of an expression.
I am using the Expr construct inside a function to create an expression,
and I would then want to use this expression in various different places.
Here's a short example
First we have a simple function "funky" that takes in a
I have a type with a lot of fields, but when I want to print it I only want
to output the name field of that type.
So when I print an array of objects of this type, I get a on the prinout an
array of names instead of a huge clutter of prints.
how might I do that?
much thanks!!
hink it gets more beautiful than this :D
>
> Best,
>
> Tamas
>
> On Sat, Feb 07 2015, Evan Pu > wrote:
>
> > say I want to compute a pair-wise diff for all the elements in the
> array.
> > input:[1, 2, 4, 7, 8]
> > output:[1, 2, 3, 1]
&
say I want to compute a pair-wise diff for all the elements in the array.
input:[1, 2, 4, 7, 8]
output:[1, 2, 3, 1]
is there some kind of "beautiful" way of doing it? i.e. w/o using a for
loop nor using explicit indecies
I'm trying to find a memory bug where all of a sudden my program freezes
and eats up all the memory.
I tried to do some printing, and tried to understand which line of code is
responsible for causing the memory leak to happen.
The print statement looks like this:
println("computing cost for...",
light table juno plugin.
literally cannot use the language w/o it haha, although it is buggy at times
On Saturday, January 17, 2015 at 11:34:46 AM UTC-5, Terry Seaward wrote:
>
> Hi,
>
> Just curious to know what people use to write/edit their Julia code
> (os/app)?
>
>
I'm trying to construct an array while making an array of pairs of floats.
The error below is extremely confusing and I have no idea why.
=
# create the array w/o type declarations works fine
julia> x = [(0.0, 1.0), (0.0, 1.0)]
2-element Array{(Flo
af(:b)),Tree(Leaf(:c))
>
>
> So this stills looks a bit clunky and you should also be aware that this
> allows for Tree(Tree(:a), Tree(1.0)) so some type constraints would be in
> order.
>
>
> On Thursday, 6 November 2014 21:52:05 UTC+1, Evan Pu wrote:
>>
>> Quick
I'll try. the call chain is rather large and I'll see if I can get it down
to a few constructs.
On Tuesday, January 13, 2015 at 4:34:39 PM UTC-5, Steven G. Johnson wrote:
>
>
>
> On Tuesday, January 13, 2015 at 4:10:54 PM UTC-5, Evan Pu wrote:
>>
>> Steven,
>
Steven,
The error is actually an issue with LightTable's Juno plugin and actually
has nothing to do with Julia.
I think what happened is in reporting the errors the plugin makes some
mistake and ended up reporting another error(or itself had some misuse of
strings) instead.
The actual error was
what is the convention? I kept getting
`convert` has no method matching convert(::Type{SubString(UTF8String)}},
::ASCIIString)
all the time, every time
I I don't really know _why_ this error comes up, or how or what. I just
kept typing :: ASCIIString trying to force the types onto things and
ho
works for me! thanks!!
On Thursday, January 8, 2015 1:07:35 PM UTC-5, Steven G. Johnson wrote:
>
> You can do Array{Int}[[1,2],[3,4]], or Vector{Int}[[1,2],[3,4]] if you
> want to restrict the entries to be 1d arrays of Int.
>
Imagine I want to initialize an array of array.
x = [[1,2],[3,4]]
but this gets flattened into [1,2,3,4]
Is there an easy way of constructing a nested array? I'm currently having
to do
x = Array{Int64}[]
push!(x, [1,2])
push!(x, [3,4])
which doesn't seem very clean
is this thread still alive? a phc package would be good...
On Monday, June 23, 2014 5:26:34 AM UTC-7, Andrei Berceanu wrote:
>
> By the way I recently stumbled upon NLSolve.jl, and asked them if they
> would be interested in PHCpack
> https://github.com/EconForge/NLsolve.jl/issues/12
>
> Still no
15, 2014, at 3:33 PM, Evan Pu >
> wrote:
>
> > 1 in [1,2,3] # returns true
> >
> > NaN in [NaN, 1.0, 2.0] # returns false
> >
> > how do I test if a float64 NaN is present in an array? I'm doing some
> numerical computation and it can have some NaN error, I want to drop the
> arrays that has NaN.
>
>
1 in [1,2,3] # returns true
NaN in [NaN, 1.0, 2.0] # returns false
how do I test if a float64 NaN is present in an array? I'm doing some
numerical computation and it can have some NaN error, I want to drop the
arrays that has NaN.
wonderful! thanks!!
On Wednesday, December 10, 2014 8:24:17 PM UTC-5, Steven G. Johnson wrote:
>
> Base.hash(p::Poly1, h::Uint) = hash(p.coef, h)
> Base.(==)(p1::Poly1, p2::Poly2) = p1.coef == p2.coef
>
> (If you override hash you should always override == to be consistent, and
> vice versa.)
>
Hi, this should be a simple affair.
I have a polynomial object that keeps track of its coefficients, it is
defined as follows:
immutable Poly1
coef :: Array{Float64}
end
I would like to make a dictionary with keys that are Poly1 type, like
follows:
# creation
r_dict1 = [Poly1([1.0, 2.0]) =>
Quick question:
In haskell one can do something like the following to define a type:
data Tree a = Branch (Tree a) (Tree a) | Leaf a
Is there something analogous in the Julia world?
I'm sure I'm doing something wrong here...
julia> type Tree
body :: Union(Branch, Leaf)
end
ERROR
Hi I'm writing a simple polynomial module which requires addition of
polynomials.
I have defined the addition by overloading the function + with an
additional method:
+(p1::Poly, p2::Poly) = ...# code for the addition
I would like to use + now in a reduce call, imagine I have a list of
polynom
>
> Regards
> Ivar
>
> kl. 19:50:31 UTC+1 tirsdag 4. november 2014 skrev Evan Pu følgende:
>>
>> Hello,
>> I want to create a polynomial type, parametrized by its coefficients,
>> able to perform polynomial additions and such.
>> but I would also like to use
Hello,
I want to create a polynomial type, parametrized by its coefficients, able
to perform polynomial additions and such.
but I would also like to use it like a function call, since a polynomial
should be just like a function
Something of the following would be nice:
p = Poly([1,2,3]) # creati
sion has to build with type Any?
>>
>>
>> On 2014年11月04日 07:06, Miguel Bazdresch wrote:
>> > > How could I force the type of gxs1 to be of an array of Float64?
>> >
>> > The simplest way is:
>> >
>> > gxs1 = Float64[g(x) for x
Consider the following interaction:
julia> g(x) = 1 / (1 + x)
g (generic function with 1 method)
julia> typeof(g(1.0))
Float64
julia> xs = [1.0, 2.0, 3.0, 4.0]
4-element Array{Float64,1}:
1.0
2.0
3.0
4.0
julia> gxs1 = [g(x) for x in xs]
4-element Array{Any,1}:
0.5
0.33
0.25
Nooo TT I was looking for it too today.
Hope it gets added soon, fingers crossed!
On Thursday, August 14, 2014 10:31:17 AM UTC-4, John Myles White wrote:
>
> Not possible in the current versions of Julia. Maybe one day. There are
> bunch of us who’d like to have this functionality, but it
yeah, the function I'm intending to inspect will be defined by me and they
shouldn't be varargs
On Thursday, October 16, 2014 2:10:34 PM UTC-4, Toivo Henningsson wrote:
>
> Though you should probably look out for varargs methods too, the length of
> e.g. (Int...) is one, but a method with that s
Consider this code:
function give_funs()
funs = []
for i in 1:5
function newfun()
i
end
funs = [funs, newfun]
end
funs
end
The intention is to create 5 functions and store them in a list called
"funs".
All the functions take no argument, and when the ith function is cal
>
> Best,
> --Tim
>
> On Thursday, October 16, 2014 08:55:01 AM Evan Pu wrote:
> > How do I get the number of arguments of a function?
> >
> > for instance, f(x, y) = x + y
> >
> > I want something like num_args(f), which will give me back 2. If
How do I get the number of arguments of a function?
for instance, f(x, y) = x + y
I want something like num_args(f), which will give me back 2. If the
function has multiple methods then something more general would be nice,
but so far I only care about functions with just a single method.
Is t
I'm assuming the function only has a single method, although a more general
answer would be nice too.
Imagine I have:
f(x,y,z) = x + y + z
I would like to have something like
num_args(f)
which should give back 3
is there something that could let me do this?
thanks a lot!!
30 matches
Mail list logo