# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=1033

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 1034

---

## [Conditional functions within functions](https://discourse.julialang.org/t/conditional-functions-within-functions/5228)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 21\
**Last updated:** [August 4, 2017, 8:07pm UTC](https://discourse.julialang.org/t/conditional-functions-within-functions/5228 "2017-08-04T20:07:18Z")

</div>

consider the following code: function foo(x::Int; d=:out) myfn = (d == :out) ? fn1 : fn2 z = 0 for i = 1:x z += myfn(i) end end I understand the inefficiency that results from the compiler not …

---

## [World age inconsistency between types and methods?](https://discourse.julialang.org/t/world-age-inconsistency-between-types-and-methods/5229)

<div class="topic-metadata">

**Author:** [@aaalexandrov](https://discourse.julialang.org/u/aaalexandrov)\
**Replies:** 0\
**Last updated:** [August 4, 2017, 7:29pm UTC](https://discourse.julialang.org/t/world-age-inconsistency-between-types-and-methods/5229 "2017-08-04T19:29:38Z")

</div>

I have a simple rendering package up that uses OpenGL to draw things. Upon loading a shader (specified in data by the user), I create a Julia immutable type to represent the vertex format as reported by OpenGL reflectio…

---

## [Is PETSc.jl alive? Any plans for Windows?](https://discourse.julialang.org/t/is-petsc-jl-alive-any-plans-for-windows/5217)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 2\
**Last updated:** [August 4, 2017, 7:01pm UTC](https://discourse.julialang.org/t/is-petsc-jl-alive-any-plans-for-windows/5217 "2017-08-04T19:01:40Z")

</div>

I wonder what does the Julia community use for solving large sparse linear systems of equations on distributed GPUs? PETSc.jl seems like an obvious option but I tried it in Windows and it is not building. So either no on…

---

## [Get a view as type Array and not as type SubArray](https://discourse.julialang.org/t/get-a-view-as-type-array-and-not-as-type-subarray/5211)

<div class="topic-metadata">

**Author:** [@thofma](https://discourse.julialang.org/u/thofma)\
**Replies:** 4\
**Last updated:** [August 4, 2017, 2:35pm UTC](https://discourse.julialang.org/t/get-a-view-as-type-array-and-not-as-type-subarray/5211 "2017-08-04T14:35:18Z")

</div>

I have an array A of type Array{T, N}. I want a view of A but for various reasons I don’t want to deal with SubArray. Is there a way to get a view of A a la view(A, ...) but not as a SubArray but as Array{T, N}? I don’t …

---

## [Using IOBuffer](https://discourse.julialang.org/t/using-iobuffer/5216)

<div class="topic-metadata">

**Author:** [@clinton](https://discourse.julialang.org/u/clinton)\
**Replies:** 4\
**Last updated:** [August 4, 2017, 4:22am UTC](https://discourse.julialang.org/t/using-iobuffer/5216 "2017-08-04T04:22:38Z")

</div>

Regarding IOBuffer, the current documentation (https://docs.julialang.org/en/stable/stdlib/io-network/) says: Create an IOBuffer, which may optionally operate on a pre-existing array. If the readable/writable argument…

---

## [Scoping rules in try blocks](https://discourse.julialang.org/t/scoping-rules-in-try-blocks/5143)

<div class="topic-metadata">

**Author:** [@musm](https://discourse.julialang.org/u/musm)\
**Replies:** 4\
**Last updated:** [August 4, 2017, 3:22am UTC](https://discourse.julialang.org/t/scoping-rules-in-try-blocks/5143 "2017-08-04T03:22:50Z")

</div>

Could anyone explain the scoping rules below (and if it is expected)? They seem rather unintuitive to me julia\> let try x = 2 end y = x + 1 end ERROR: UndefVarError: x not defined …

---

## [Why does an if statement force a value to be boxed?](https://discourse.julialang.org/t/why-does-an-if-statement-force-a-value-to-be-boxed/5214)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 3\
**Last updated:** [August 4, 2017, 12:25am UTC](https://discourse.julialang.org/t/why-does-an-if-statement-force-a-value-to-be-boxed/5214 "2017-08-04T00:25:58Z")

</div>

Consider this simple function, which is type stable and always returns an Int: function no\_box(lambda::Float64) alpha = lambda / 30.0 n = 50 return sum(rand() \< alpha for i in 1:n) end julia\> @code\_warntype no\_box(25…

---

## [How to maintain performance despite type instability when you know the type?](https://discourse.julialang.org/t/how-to-maintain-performance-despite-type-instability-when-you-know-the-type/5210)

<div class="topic-metadata">

**Author:** [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Replies:** 5\
**Last updated:** [August 3, 2017, 8:34pm UTC](https://discourse.julialang.org/t/how-to-maintain-performance-despite-type-instability-when-you-know-the-type/5210 "2017-08-03T20:34:59Z")

</div>

I have an example of type instability. My goal is to evaluate a function on a grid of points, but the dimensionality of the grid is determined by determining the rank of the Hessian matrix. The grid and various StaticA…

---

## [Proper way to declare return types parametrically in short-form functions in Julia 0.6](https://discourse.julialang.org/t/proper-way-to-declare-return-types-parametrically-in-short-form-functions-in-julia-0-6/5212)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 1\
**Last updated:** [August 3, 2017, 9:03pm UTC](https://discourse.julialang.org/t/proper-way-to-declare-return-types-parametrically-in-short-form-functions-in-julia-0-6/5212 "2017-08-03T21:03:36Z")

</div>

In Julia 0.5, I was able to declare the return type with a type parameter as follows: julia\> test{T\<:Number}(x::T)::float(T) = x test (generic function with 1 method) julia\> test(1) 1.0 However, in Julia 0.6 with the w…

---

## [Cannot install packages](https://discourse.julialang.org/t/cannot-install-packages/5201)

<div class="topic-metadata">

**Author:** [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Replies:** 3\
**Last updated:** [August 3, 2017, 8:29pm UTC](https://discourse.julialang.org/t/cannot-install-packages/5201 "2017-08-03T20:29:52Z")

</div>

I cannot install any packages today. Even after deleting my .julia directory and running Pkg.add("HDF5") (having problems with WinRPM again) the response is: ERROR: Cannot clone BinDeps from https://github.com/JuliaLang…

---

## [Way to make CLI in Julia?](https://discourse.julialang.org/t/way-to-make-cli-in-julia/5171)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 20\
**Last updated:** [August 3, 2017, 8:15pm UTC](https://discourse.julialang.org/t/way-to-make-cli-in-julia/5171 "2017-08-03T20:15:35Z")

</div>

Let’s say I’ve been using the following alias: alias julz="julia -L ~/.julia/v0.6/Julz/src/functions/utils/cli.jl -e 'cli()' --" However I think this is a little hacky and want an actual bash cmd // like how python or …

---

## [VoronoiDelaunay.jl difficulties](https://discourse.julialang.org/t/voronoidelaunay-jl-difficulties/5206)

<div class="topic-metadata">

**Author:** [@healyp](https://discourse.julialang.org/u/healyp)\
**Replies:** 2\
**Last updated:** [August 3, 2017, 7:44pm UTC](https://discourse.julialang.org/t/voronoidelaunay-jl-difficulties/5206 "2017-08-03T19:44:39Z")

</div>

\[Sorry, this is probably not the most appropriate group for this question.\] I’m having difficulty reproducing the intoductory example of the VoronoiDelaunay documentation. using VoronoiDelaunay tess = DelaunayTessella…

---

## [Stack trace reversed in juno](https://discourse.julialang.org/t/stack-trace-reversed-in-juno/5199)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 3\
**Last updated:** [August 3, 2017, 6:16pm UTC](https://discourse.julialang.org/t/stack-trace-reversed-in-juno/5199 "2017-08-03T18:16:34Z")

</div>

When given a stack trace in the REPL, the innermost call is displayed on top, and the outermost in the bottom. In error pop-ups in Atom/Juno, this order is reversed, with the innermost call in the bottom. It may seem lik…

---

## [Composite Type Registering as Any with @code\_warntype](https://discourse.julialang.org/t/composite-type-registering-as-any-with-code-warntype/5196)

<div class="topic-metadata">

**Author:** [@Kaela\_Martin](https://discourse.julialang.org/u/Kaela_Martin)\
**Replies:** 3\
**Last updated:** [August 3, 2017, 2:55pm UTC](https://discourse.julialang.org/t/composite-type-registering-as-any-with-code-warntype/5196 "2017-08-03T14:55:37Z")

</div>

When I pass a composite type into a function, it doesn’t seem to know the element type even if it is explicitly defined. Should Julia be able to infer the type? type TEST Notes::AbstractArray{Float64} Time::Float64 …

---

## [Method for array of arrays](https://discourse.julialang.org/t/method-for-array-of-arrays/5183)

<div class="topic-metadata">

**Author:** [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Replies:** 5\
**Last updated:** [August 3, 2017, 1:40am UTC](https://discourse.julialang.org/t/method-for-array-of-arrays/5183 "2017-08-03T01:40:07Z")

</div>

I’d like to write a method for an array of arrays, for example simple(g::Array{Array{Float64}}) = g should be an identity function. But if try A = \[1. 2.; 3. 4.\] B = \[5. 6. 7.; 8. 9. 0.\] g = \[A, B\] simple(g) I get …

---

## [Working with multiple files](https://discourse.julialang.org/t/working-with-multiple-files/5190)

<div class="topic-metadata">

**Author:** [@clinton](https://discourse.julialang.org/u/clinton)\
**Replies:** 12\
**Last updated:** [August 2, 2017, 11:45pm UTC](https://discourse.julialang.org/t/working-with-multiple-files/5190 "2017-08-02T23:45:42Z")

</div>

I’m missing something as far as how to work with multiple files. I have a directory where I keep two \*.jl files, say “core.jl” and “scripts.jl” One has most of the core analytical code, the other has some very project s…

---

## ["where" - where?](https://discourse.julialang.org/t/where-where/5188)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 1\
**Last updated:** [August 2, 2017, 6:20pm UTC](https://discourse.julialang.org/t/where-where/5188 "2017-08-02T18:20:59Z")

</div>

The following quote is an excerpt from the latest version of the manual: (Equivalently, one could define function norm{T\<:Real}(p::Point{T}) or function norm(p::Point{T} where T\<:Real); see UnionAll Types.) Notice how …

---

## [Optimal way to do in-place modification of sparse matrix?](https://discourse.julialang.org/t/optimal-way-to-do-in-place-modification-of-sparse-matrix/5170)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 4\
**Last updated:** [August 2, 2017, 3:59pm UTC](https://discourse.julialang.org/t/optimal-way-to-do-in-place-modification-of-sparse-matrix/5170 "2017-08-02T15:59:42Z")

</div>

I’m looking for the most performant way to modify a large SparseMatrixCSC in-place. The matrix is initially built using the sp = sparse(I,J,K) method. Later, I need to modify only the non-zero entries in sp. I’m tempted …

---

## [Way to return the number of allocations?](https://discourse.julialang.org/t/way-to-return-the-number-of-allocations/5167)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 10\
**Last updated:** [August 2, 2017, 2:01am UTC](https://discourse.julialang.org/t/way-to-return-the-number-of-allocations/5167 "2017-08-02T02:01:56Z")

</div>

Is there a way to return the number of allocations used in a code? For example, I want to get the number 5 of the 5 allocations in the following example: julia\> using BenchmarkTools julia\> @btime \[1,1,1\]+\[2,2,2\]+\[3,3,…

---

## [Using Julia & GTK for 3D-Plots/ Visuals](https://discourse.julialang.org/t/using-julia-gtk-for-3d-plots-visuals/5156)

<div class="topic-metadata">

**Author:** [@Rae](https://discourse.julialang.org/u/Rae)\
**Replies:** 10\
**Last updated:** [August 1, 2017, 9:16pm UTC](https://discourse.julialang.org/t/using-julia-gtk-for-3d-plots-visuals/5156 "2017-08-01T21:16:37Z")

</div>

Hi All! I’m currently working on a building a GUI using Julia & GTK, but I would like to display 3D-plots and 3D visuals (animations or CAD models) to my GUI. How can I display these visuals onto my GUI? Many Thanks, …

---

## [Broadcasted equal of tuples](https://discourse.julialang.org/t/broadcasted-equal-of-tuples/5160)

<div class="topic-metadata">

**Author:** [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Replies:** 4\
**Last updated:** [August 1, 2017, 1:20pm UTC](https://discourse.julialang.org/t/broadcasted-equal-of-tuples/5160 "2017-08-01T13:20:21Z")

</div>

I’m not sure this is a bug or a well though change but I see a huge discrepancy in results: #v0.5.1 (win64, binnary): foo = (1, 0.5) bar = \[foo, foo\] foo .== bar 2-element BitArray{1}: true true …

---

## [Stop-julia keybinding in Juno](https://discourse.julialang.org/t/stop-julia-keybinding-in-juno/5164)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 3\
**Last updated:** [August 1, 2017, 12:46pm UTC](https://discourse.julialang.org/t/stop-julia-keybinding-in-juno/5164 "2017-08-01T12:46:24Z")

</div>

I would like to add a keybinding top stop the current julia process in Juno, Atom. I can’t seem to figure out if this is possible or not. Stop julia does not appear in the command palette either, whereas start-julia does…

---

## [show(io::IO, custom matrix) is not called?](https://discourse.julialang.org/t/show-io-io-custom-matrix-is-not-called/5161)

<div class="topic-metadata">

**Author:** [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)\
**Replies:** 3\
**Last updated:** [August 1, 2017, 11:46am UTC](https://discourse.julialang.org/t/show-io-io-custom-matrix-is-not-called/5161 "2017-08-01T11:46:57Z")

</div>

Hi, I’m trying to show my custom matrix type to display by overloading the Base.show method, but it doesn’t call the overloaded method. The following is a reproducible code: # https://github.com/BioJulia/BioSymbols.jl …

---

## [Using Julia on campus computers w cloud file storage](https://discourse.julialang.org/t/using-julia-on-campus-computers-w-cloud-file-storage/5157)

<div class="topic-metadata">

**Author:** [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Replies:** 4\
**Last updated:** [August 1, 2017, 5:59am UTC](https://discourse.julialang.org/t/using-julia-on-campus-computers-w-cloud-file-storage/5157 "2017-08-01T05:59:29Z")

</div>

How do people who teach Julia in the classroom reconcile Julia’s caching of packages in user-specific $JULIA\_PKGDIR directories (e.g. ~/.julia) with the lack of user-specific local storage on typical classroom computers…

---

## [What to do with a Travis failure?](https://discourse.julialang.org/t/what-to-do-with-a-travis-failure/5152)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [August 1, 2017, 5:42am UTC](https://discourse.julialang.org/t/what-to-do-with-a-travis-failure/5152 "2017-08-01T05:42:22Z")

</div>

This may be a trivial question: what to do with a Travis (nightly version) failure? The test reports a segmentation error somewhere in the LLVM.dll. Is this something that I should report as an issue? Or is this in gene…

---

## [ANN: Human-friendly numeric output (NumericIO)](https://discourse.julialang.org/t/ann-human-friendly-numeric-output-numericio/5159)

<div class="topic-metadata">

**Author:** [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Replies:** 0\
**Last updated:** [August 1, 2017, 12:30am UTC](https://discourse.julialang.org/t/ann-human-friendly-numeric-output-numericio/5159 "2017-08-01T00:30:57Z")

</div>

NumericIO provides fine control over numeric output: Scientific/Engineering/SI-notation +UTF8: Includes facilities to display values using SI prefixes (Y, Z, E, P, T, G, M, k, m, μ, n, p, f, a, z, y) Makes it easy to c…

---

## [How to interpolate symbol as symbol, not as variable name?](https://discourse.julialang.org/t/how-to-interpolate-symbol-as-symbol-not-as-variable-name/5158)

<div class="topic-metadata">

**Author:** [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Replies:** 2\
**Last updated:** [July 31, 2017, 11:14pm UTC](https://discourse.julialang.org/t/how-to-interpolate-symbol-as-symbol-not-as-variable-name/5158 "2017-07-31T23:14:29Z")

</div>

Given a list of keys, I want to generate expressions for getting the keys from a predefined dictionary. E.g. for string keys: ks = \["x", "y"\] result = \[:(d\[$k\]) for k in ks\] # ==\> 2-element Array{Expr,1}: …

---

## [Cannot use PyPlot](https://discourse.julialang.org/t/cannot-use-pyplot/5153)

<div class="topic-metadata">

**Author:** [@Wilson\_Chen](https://discourse.julialang.org/u/Wilson_Chen)\
**Replies:** 2\
**Last updated:** [July 31, 2017, 5:03pm UTC](https://discourse.julialang.org/t/cannot-use-pyplot/5153 "2017-07-31T17:03:00Z")

</div>

---

## [How to change the priority of an item in a DataStructures.PriorityQueue?](https://discourse.julialang.org/t/how-to-change-the-priority-of-an-item-in-a-datastructures-priorityqueue/5138)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 5\
**Last updated:** [July 31, 2017, 8:01am UTC](https://discourse.julialang.org/t/how-to-change-the-priority-of-an-item-in-a-datastructures-priorityqueue/5138 "2017-07-31T08:01:48Z")

</div>

Can I remove an item from a DataStructures.PriorityQueue, other than the lowest priority? Alternatively, can I change the priority of an item inside a PriorityQueue?

---

## [Why Abstract Type is slow?](https://discourse.julialang.org/t/why-abstract-type-is-slow/5146)

<div class="topic-metadata">

**Author:** [@usefulhyun](https://discourse.julialang.org/u/usefulhyun)\
**Replies:** 1\
**Last updated:** [July 31, 2017, 4:26am UTC](https://discourse.julialang.org/t/why-abstract-type-is-slow/5146 "2017-07-31T04:26:14Z")

</div>

Can anyone answer about this question? Why use of Integer type makes program slower. If you run the below code, you might see it takes about 0.13 second to use the data of type UnitRange{Integer}. repetition = 30 mat …

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=1032)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=1034)
