There is no need to do this in Julia; you can simply initialize in the
default argument.
function f(x; y=[x, x, x])
@show x y
end
then
julia> f(1)
x = 1
y = [1,1,1]
because in Julia, unlike Python, the initialization is done at calltime
instead of function definition time.
On Friday,
It is also possible to use @type and @immutable, although the macros are
slightly harder to define.
macro lit_str(s); Symbol(s); end
macro lit"type"(x)
...
end
macro lit"immutable"(x)
...
end
@type ...
@immutable ...
On Saturday, October 29, 2016 at 6:16:37 PM UTC-4, Jake Rosoman
The `showall` function does this.
On Monday, October 10, 2016 at 3:16:20 PM UTC-4, John Paul Vasquez wrote:
>
> Is there a command/option to display all the elements of a very long
> array? The output gets cut in the middle. For example when calling
> Pkg.available(), I only see the head and
As Jussi Piitulainen noted, the ^ operator is backwards, so you need to
wrap it around a function.
On Friday, October 7, 2016 at 10:05:34 AM UTC-4, Kevin Liu wrote:
>
> *julia> **@code_native(b^a)*
>
>.section__TEXT,__text,regular,pure_instructions
>
> Filename: bool.jl
>
>
HackerRank supports Julia in its Algorithms domain and related contests. I
sent a support request to extend this to the Mathematics domain.
On Monday, June 27, 2016 at 10:39:52 PM UTC-4, Андрей Логунов wrote:
>
> Are there any projects/initiatives to apply Julia with online judge
> systems
The ^ operator can be used for implication. Due to Curry-Howard,
implication is isomorphic to function abstraction, which combinatorially
can be counted using the exponentiation function.
On Thursday, October 6, 2016 at 12:10:51 PM UTC-4, Kevin Liu wrote:
>
> How is an implication represented
I think you have misunderstood Kristoffer. It's possible the Int values
themselves are of distinct types; note for instance
julia> Array{Int, Int32(1)}
Array{Int64,1}
julia> Array{Int, 1}
Array{Int64,1}
julia> Array{Int, Int32(1)} == Array{Int, 1}
false
On Thursday, October 6, 2016 at
I would also personally prefer a Discourse-based forum to this Google
Groups mailing list.
On Saturday, September 19, 2015 at 8:16:36 PM UTC-4, Jonathan Malmaud wrote:
>
> Hi all,
> There's been some chatter about maybe switching to a new, more modern
> forum platform for Julia that could
It is not in general possible to recover the function itself from a method,
as methods are specific to types and not functions. Multiple functions can
share methods if those functions have the same type.
In the case of generic (or singleton) functions, you can recover the
function from the
There should be no copy if you reshape a view.
julia> reshape((@view x[1:6]), (3, 2))
3×2
Base.ReshapedArray{Float64,2,SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},Tuple{}}:
1.0 1.0
1.0 1.0
1.0 1.0
On Sunday, October 2, 2016 at 8:43:01 AM UTC-4, Alexey Cherkaev
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
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
, 2016 at 4:50:26 PM UTC, Fengyang Wang wrote:
>>
>> but type piracy is bad practice. This method should really be in Base.
>>
>
> As always, if something, should be in Base or Julia, then I think a PR is
> welcome.
>
> [Maybe I do not fully understand this (yes, t
There is no need to modify a copy; only the Nullable is immutable and not
its underlying value. Just instead of modifying ec.title, modify
get(ec.title). Like setfield!(get(ec.title), k, v). In short scripts, I
often define getindex(x::Nullable) = get(x) so that I can write ec.title[]
instead
I wonder why this is desirable. A type instability in the array type is
unlikely to be of much concern, because the cost of array operations will
wildly overshadow the cost of a dynamic dispatch. Once the array passes a
function barrier, its eltype becomes inferrable. A type instability in a
In addition to Mauro's answer, programatically, you can do
which(issymmetric, Tuple{typeof(fill(NaN, 1, 1))}), which is almost your
preferred syntax.
julia> foo(x) = 0
foo (generic function with 1 method)
julia> foo(x::Int) = 0.0
foo (generic function with 2 methods)
julia> foo.(Any[1, 2, 3])
3-element Array{Float64,1}:
0.0
0.0
0.0
julia> foo.(Number[1, 2, 3])
3-element Array{Number,1}:
0.0
0.0
0.0
My understanding was that the actual
This is an intuitive explanation, but the mathematics of IEEE floating
points seem to be designed so that 0.0 represents a "really small positive
number" and -0.0 represents "exact zero" or at least "an even smaller
really small negative number"; hence -0.0 + 0.0 = 0.0. I never understood
this
Should application/julia perhaps be recognized as a text MIME, then?
julia> istextmime("application/julia")
false
julia> istextmime("application/javascript")
true
A PR making this change: https://github.com/JuliaLang/julia/pull/18441
What is the standard MIME type for Julia code?
My reading of the MIME standard leads to me think
application/x-julia
is the accurate choice. However, I could only find few results on Google,
and Julia doesn't currently recognize this as a text MIME.
On Monday, August 8, 2016 at 10:26:46 AM UTC-4, Kevin Squire wrote:
>
> Try
>
> import Base.(!)
>
> Cheers,
> Kevin
>
Why do import statements have different syntax? This syntax, I'm pretty
sure, has either meant getfield or broadcast—in neither case does it
actually refer to the !
Generally, pointers returned from ccalls should be freed with the free
function from the same library. From the documentation of Libc.free:
Call free from the C standard library. Only use this on memory obtained from
> malloc, not on pointers retrieved from other C libraries. Ptr objects
>
Hi Ferran,
Just a quick note that any solution (including Mauro's) *must* make a
copy—as the original vectors are not contiguous in memory, they have to be
copied to form an array.
let is lowered to what is basically a function that's executed immediately.
It should have identical performance on 0.5.
On Friday, July 1, 2016 at 10:31:20 AM UTC-4, David Gold wrote:
>
> Depends which version you're on. On 0.5, where anonymous functions are
> performant, I think the way to go
I don't know about performance or correctness, but it *is* possible to do
something like this:
x :: SomeType{X, TypeVar(:T), Z}
but I think the typealias is a better solution.
The typealias is the best solution I know of.
This would be one form of tech evangelism. I wonder if there are any
communities set up for Julia evangelism?
This can't work because it would not, for instance, make sense to use
module `M` independently. You could use the parent module from `M`, but as
it stands that won't work either because loading the parent module will try
to use `f` from `M`. What are you trying to do?
On Monday, June 20, 2016
Are you using solarized, by any chance? That terminal theme is notorious
for changing around the meaning of colours. I would avoid it if possible.
>
> On Saturday, February 6, 2016, Fengyang Wang <fengya...@gmail.com
> > wrote:
>
>> I was looking for a Julia package to handle rational functions, when I
>> noticed that the `Polynomials` package implements `gcd`, `div`, and `rem`.
>> So it would be possibl
I was looking for a Julia package to handle rational functions, when I
noticed that the `Polynomials` package implements `gcd`, `div`, and `rem`.
So it would be possible to simply use `Rational{Poly}`... or so I thought.
Unfortunately, the type `Rational` prevents this use, since it requires
collect(UInt8, "hello world")
should do the trick.
On Saturday, February 6, 2016 at 8:31:19 PM UTC-5, icebl...@gmail.com wrote:
>
> Hello,
>
> I m trying to convert ASCIIString (or ASCII) to Uint8 .
>
> b"string" seems to be the option. However it doesnt seem to handle
> b"$(variable)"
>
>
On Wednesday, August 26, 2015 at 1:17:06 PM UTC-4, Stefan Karpinski wrote:
Is JavaScript actually easy to integrate with Java?
Java has always come bundled with a Javascript interpreter (first Rhino,
now Nashorn). It can be used like this:
*package sample1;*
*import
Thank you for your response! This has been very helpful.
Hi,
I learned Julia recently, and I must say it has been incredible for
scientific work. I am in love with the clean, modern syntax. Props to the
developers for their tireless efforts to improve this language even further!
Historically, Lua and Javascript have been the most common choices for
35 matches
Mail list logo