# General Usage

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

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

**Page:** 215

---

## [How to avoid collect an iterator returning a vector of Any](https://discourse.julialang.org/t/how-to-avoid-collect-an-iterator-returning-a-vector-of-any/108400)

<div class="topic-metadata">

**Author:** [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Replies:** 1\
**Last updated:** [January 5, 2024, 6:05pm UTC](https://discourse.julialang.org/t/how-to-avoid-collect-an-iterator-returning-a-vector-of-any/108400 "2024-01-05T18:05:45Z")

</div>

Hello, I have the following code using OnlineStatsBase using IncTA using IncTA: TechnicalIndicator using IncTA.SampleData: OPEN\_TMPL, HIGH\_TMPL, LOW\_TMPL, CLOSE\_TMPL, VOLUME\_TMPL, DATE\_TMPL mutable struct TechnicalIn…

---

## [Getting current scene azimuth and elevation](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380)

<div class="topic-metadata">

**Author:** [@sijo](https://discourse.julialang.org/u/sijo)\
**Replies:** 2\
**Last updated:** [January 5, 2024, 2:05pm UTC](https://discourse.julialang.org/t/getting-current-scene-azimuth-and-elevation/108380 "2024-01-05T14:05:05Z")

</div>

Makie 0.20 has added a method update\_cam!(scene, azimuth, elevation). Is there an easy way to go in the other direction, to get the azimuth and elevation values corresponding to the current scene configuration? These va…

---

## [Swap cols/rows of a matrix](https://discourse.julialang.org/t/swap-cols-rows-of-a-matrix/47904)

<div class="topic-metadata">

**Author:** [@hytonwons](https://discourse.julialang.org/u/hytonwons)\
**Replies:** 15\
**Last updated:** [January 5, 2024, 8:57am UTC](https://discourse.julialang.org/t/swap-cols-rows-of-a-matrix/47904 "2024-01-05T08:57:03Z")

</div>

Hi, I need to swap columns or rows of a matrix. I have two ideas: (1). Create a new matrix and copy cols/rows to the new matrix. We may use @view. (2). Multiply by a permutation matrix. Of course, we also need to crea…

---

## [Equivalent Fortran function is about 4.6 times faster](https://discourse.julialang.org/t/equivalent-fortran-function-is-about-4-6-times-faster/108344)

<div class="topic-metadata">

**Author:** [@jabru](https://discourse.julialang.org/u/jabru)\
**Replies:** 17\
**Last updated:** [January 5, 2024, 8:02am UTC](https://discourse.julialang.org/t/equivalent-fortran-function-is-about-4-6-times-faster/108344 "2024-01-05T08:02:08Z")

</div>

Hey there, for my current project, I wrote a function in plane Julia. It reads #Kappa squared or the square of the inverse debye length Debyelengthinnversesquared(is) = e^2\*beta\*2\*is\*n\_a/(epsilon\*epsilon\_r) #Kappa in …

---

## [Array comprehension in a quote](https://discourse.julialang.org/t/array-comprehension-in-a-quote/108333)

<div class="topic-metadata">

**Author:** [@lstagner](https://discourse.julialang.org/u/lstagner)\
**Replies:** 4\
**Last updated:** [January 5, 2024, 4:33am UTC](https://discourse.julialang.org/t/array-comprehension-in-a-quote/108333 "2024-01-05T04:33:13Z")

</div>

I want to do an array comprehension from a list of ranges in a quote but I get a syntax error. loops = \[:(i=1:2), :(j=1:3)\] :(\[i+j for :(loops...)\]) # ideally maps to \[i+j for i=1:2, j=1:3\] syntax: invalid iteration spe…

---

## [@ccall: returning a pointer to an array](https://discourse.julialang.org/t/ccall-returning-a-pointer-to-an-array/108329)

<div class="topic-metadata">

**Author:** [@rmfritz](https://discourse.julialang.org/u/rmfritz)\
**Replies:** 4\
**Last updated:** [January 5, 2024, 4:13am UTC](https://discourse.julialang.org/t/ccall-returning-a-pointer-to-an-array/108329 "2024-01-05T04:13:09Z")

</div>

I am trying to wrap a C function that returns a pointer to an array of UInt8, and I can’t quite figure out how to pass that pointer in. The C function signature is: int tmMapPicture(uby8 \*\*psp, int \*xp, int \*yp, … A p…

---

## [Using types as parameters of a function](https://discourse.julialang.org/t/using-types-as-parameters-of-a-function/108342)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 8:01pm UTC](https://discourse.julialang.org/t/using-types-as-parameters-of-a-function/108342 "2024-01-04T20:01:33Z")

</div>

We have the following code: abstract type MyType end struct MyType1 \<: MyType end myfun(::MyType1, x, args...) = x How can I call the function ‘myfun’? julia\> myfun(::MyType1, 2) ERROR: syntax: invalid "::" sy…

---

## [Deconstructing UnionAll types](https://discourse.julialang.org/t/deconstructing-unionall-types/108328)

<div class="topic-metadata">

**Author:** [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 7:41pm UTC](https://discourse.julialang.org/t/deconstructing-unionall-types/108328 "2024-01-04T19:41:37Z")

</div>

The following naive definition is invalid, but you don’t realize it until you try it: julia\> f(::Type{Set{\<:W}} where W) = W f (generic function with 4 methods) Here goes… julia\> f(Set{\<:Integer}) ERROR: UndefVarError…

---

## [Object paths across julia modules](https://discourse.julialang.org/t/object-paths-across-julia-modules/108195)

<div class="topic-metadata">

**Author:** [@thomaskroi1996](https://discourse.julialang.org/u/thomaskroi1996)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 6:49pm UTC](https://discourse.julialang.org/t/object-paths-across-julia-modules/108195 "2024-01-04T18:49:15Z")

</div>

Hey everyone! I am currently developing a package and I have encountered a small problem. Imagine the following situation. I have a module1 and module2, full of functions and a module3 full of objects/structs. This is …

---

## [Line number info missing when Windows DLL gets EXCEPTION\_ACCESS\_VIOLATION](https://discourse.julialang.org/t/line-number-info-missing-when-windows-dll-gets-exception-access-violation/108353)

<div class="topic-metadata">

**Author:** [@Kirby\_Zhang](https://discourse.julialang.org/u/Kirby_Zhang)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 6:32pm UTC](https://discourse.julialang.org/t/line-number-info-missing-when-windows-dll-gets-exception-access-violation/108353 "2024-01-04T18:32:53Z")

</div>

The DLL was compiled using MSVC toolchain with debug configuration. A .pdb file was generated alongside the .dll file. But it seems line number information is not being made available to Julia’s access violation handler: …

---

## [Error from conversion of missing values to NaNs](https://discourse.julialang.org/t/error-from-conversion-of-missing-values-to-nans/108321)

<div class="topic-metadata">

**Author:** [@Leon6](https://discourse.julialang.org/u/Leon6)\
**Replies:** 12\
**Last updated:** [January 4, 2024, 2:35pm UTC](https://discourse.julialang.org/t/error-from-conversion-of-missing-values-to-nans/108321 "2024-01-04T14:35:35Z")

</div>

A is a value I read out of an NetCDF file (32 bit). Its size is 360x180x30. Here is my code to convert its missing values into NaNs: A\[ismissing.(A)\] .= NaN; Why does the above script work perfectly fine, but every t…

---

## [Embedding Julia: GC race conditions](https://discourse.julialang.org/t/embedding-julia-gc-race-conditions/108346)

<div class="topic-metadata">

**Author:** [@sijo](https://discourse.julialang.org/u/sijo)\
**Replies:** 0\
**Last updated:** [January 4, 2024, 2:29pm UTC](https://discourse.julialang.org/t/embedding-julia-gc-race-conditions/108346 "2024-01-04T14:29:27Z")

</div>

I’m trying to understand how GC interaction from C works in case of multiple threads. How are race conditions avoided? The manual says: When writing code that embeds Julia, it is generally safe to use jl\_value\_t\* valu…

---

## [REPL.TerminalMenus RadioMenu pre-selected option distinct from first one](https://discourse.julialang.org/t/repl-terminalmenus-radiomenu-pre-selected-option-distinct-from-first-one/108345)

<div class="topic-metadata">

**Author:** [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Replies:** 1\
**Last updated:** [January 4, 2024, 2:21pm UTC](https://discourse.julialang.org/t/repl-terminalmenus-radiomenu-pre-selected-option-distinct-from-first-one/108345 "2024-01-04T14:21:53Z")

</div>

Hi there, Does the RadioMenu command from the REPL.TerminalMenus module have an argument that allows, for convenience, to have the default pre-selected option different from the first one? I mean something like: orange…

---

## [Dynamically create Struct](https://discourse.julialang.org/t/dynamically-create-struct/108259)

<div class="topic-metadata">

**Author:** [@fdekerme](https://discourse.julialang.org/u/fdekerme)\
**Replies:** 12\
**Last updated:** [January 4, 2024, 1:53pm UTC](https://discourse.julialang.org/t/dynamically-create-struct/108259 "2024-01-04T13:53:10Z")

</div>

Hello everyone :grin:! I am working on a compartment model for a Markov chain simulation. The parameters of the compartment model (name of each compartment and transition matrix) are defined in an excel file. A Compartm…

---

## [Is it possible to detect garbage collection on a custom struct?](https://discourse.julialang.org/t/is-it-possible-to-detect-garbage-collection-on-a-custom-struct/108338)

<div class="topic-metadata">

**Author:** [@ThummeTo](https://discourse.julialang.org/u/ThummeTo)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 1:02pm UTC](https://discourse.julialang.org/t/is-it-possible-to-detect-garbage-collection-on-a-custom-struct/108338 "2024-01-04T13:02:48Z")

</div>

Hi! I am using an external library (LIB or DLL) to allocate and free memory that is not in the scope of the garbage collector, in the following example externalAlloc and externalFree. For better handling, I packed the m…

---

## [show(\[io::IO = stdout\], x), the keyword argument is not at the end?](https://discourse.julialang.org/t/show-io-io-stdout-x-the-keyword-argument-is-not-at-the-end/108339)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 1\
**Last updated:** [January 4, 2024, 1:04pm UTC](https://discourse.julialang.org/t/show-io-io-stdout-x-the-keyword-argument-is-not-at-the-end/108339 "2024-01-04T13:04:33Z")

</div>

help?\> show search: show showable showerror @show @showtime Cshort Cushort hasmethod searchsorted searchsortedlast searchsortedfirst show(\[io::IO = stdout\], x) Write a text representation of a value x to the output…

---

## [Type stability with type as argument and permutedims](https://discourse.julialang.org/t/type-stability-with-type-as-argument-and-permutedims/108335)

<div class="topic-metadata">

**Author:** [@snowgum](https://discourse.julialang.org/u/snowgum)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 12:08pm UTC](https://discourse.julialang.org/t/type-stability-with-type-as-argument-and-permutedims/108335 "2024-01-04T12:08:48Z")

</div>

I am experiencing poor performance (maybe type unstable?) when having a type as an optional argument to a function, and using permutedims inside. I’m having difficulty understanding why the first function is much slower …

---

## [Makie: Errorbars for grouped bar graphs](https://discourse.julialang.org/t/makie-errorbars-for-grouped-bar-graphs/62361)

<div class="topic-metadata">

**Author:** [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Replies:** 13\
**Last updated:** [January 4, 2024, 9:21am UTC](https://discourse.julialang.org/t/makie-errorbars-for-grouped-bar-graphs/62361 "2024-01-04T09:21:29Z")

</div>

How can I add errorbars to a grouped bar plot in Makie.jl? One option is to use crossbar, but this generates a bar graph indicating the error range, not the usual line + whisker.

---

## [Global variable issue](https://discourse.julialang.org/t/global-variable-issue/108288)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 28\
**Last updated:** [January 4, 2024, 6:24am UTC](https://discourse.julialang.org/t/global-variable-issue/108288 "2024-01-04T06:24:20Z")

</div>

It is quite strange that with the following code N = 10 M = 10 dim = binomial(N+M-1, M-1) basis=zeros(Int8, M, dim) basis\[1,1\]=N s=1 while basis\[M,s\]\<N s1=M-1 while basis\[s1,s\]==0 s1=s1-1 end …

---

## ['Int' as a reserved word](https://discourse.julialang.org/t/int-as-a-reserved-word/108322)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 6:17am UTC](https://discourse.julialang.org/t/int-as-a-reserved-word/108322 "2024-01-04T06:17:28Z")

</div>

My code has such a line Int=sparse(COO1\[1,:\],COO1\[2,:\],COO1\[3,:\],dim,dim) It got an error: ERROR: cannot assign a value to imported variable Core.Int from module Main It seems that ‘Int’ is a reserved word of julia. …

---

## [The same name for a function and a variable](https://discourse.julialang.org/t/the-same-name-for-a-function-and-a-variable/108325)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 2\
**Last updated:** [January 4, 2024, 3:17am UTC](https://discourse.julialang.org/t/the-same-name-for-a-function-and-a-variable/108325 "2024-01-04T03:17:29Z")

</div>

julia\> function dis(x, y) return dis = sqrt(x^2 + y^2) end dis (generic function with 1 method) julia\> a = dis(1, 2) 2.23606797749979 julia\> dis = dis(1,2) ERROR: invalid redefinition of constant dis Sta…

---

## [Deserialize a dictionnary and removing one element](https://discourse.julialang.org/t/deserialize-a-dictionnary-and-removing-one-element/108312)

<div class="topic-metadata">

**Author:** [@virgile-baudrot](https://discourse.julialang.org/u/virgile-baudrot)\
**Replies:** 0\
**Last updated:** [January 3, 2024, 5:33pm UTC](https://discourse.julialang.org/t/deserialize-a-dictionnary-and-removing-one-element/108312 "2024-01-03T17:33:06Z")

</div>

I saved a dictionnary using the Serialization package. It worked well. Unfortunatelly one of the element was bad defined (a function with elements not recognize… which I do not understand why since I thought it was comp…

---

## [Gtk GUI + returning a value from a function](https://discourse.julialang.org/t/gtk-gui-returning-a-value-from-a-function/108299)

<div class="topic-metadata">

**Author:** [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)\
**Replies:** 2\
**Last updated:** [January 3, 2024, 5:00pm UTC](https://discourse.julialang.org/t/gtk-gui-returning-a-value-from-a-function/108299 "2024-01-03T17:00:48Z")

</div>

Hi, I’m using Gtk to display GUI inside my function. I’d like the function to return a value generated in that GUI, e.g. Gtk.GtkSpinButton value. How can this be done? I need to keep the window open until the value is s…

---

## [Best practices for organizing objects](https://discourse.julialang.org/t/best-practices-for-organizing-objects/108305)

<div class="topic-metadata">

**Author:** [@Gast](https://discourse.julialang.org/u/Gast)\
**Replies:** 3\
**Last updated:** [January 3, 2024, 4:45pm UTC](https://discourse.julialang.org/t/best-practices-for-organizing-objects/108305 "2024-01-03T16:45:47Z")

</div>

I wonder if how I call objects through different functions is the ‘best way’ of doing it (or if at least is in line with Julia’s best practices). A general example of what I am doing is below. All objects needed in my p…

---

## [ProfileView.jl makes my computer lag](https://discourse.julialang.org/t/profileview-jl-makes-my-computer-lag/98729)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 10\
**Last updated:** [January 3, 2024, 4:27pm UTC](https://discourse.julialang.org/t/profileview-jl-makes-my-computer-lag/98729 "2024-01-03T16:27:18Z")

</div>

Hello, Since I’ve updated to 1.9, julia makes my computer extremely slow. Note that I also tried with 1.8.5 and it also happens, it coincides with me upgrading to 1.9, but doesn’t seem linked to the version itself. I’m…

---

## [Adaptive time-stepping for semi-linear ODE (Kuramoto-Sivashinsky)](https://discourse.julialang.org/t/adaptive-time-stepping-for-semi-linear-ode-kuramoto-sivashinsky/108274)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 3\
**Last updated:** [January 3, 2024, 2:34pm UTC](https://discourse.julialang.org/t/adaptive-time-stepping-for-semi-linear-ode-kuramoto-sivashinsky/108274 "2024-01-03T14:34:33Z")

</div>

Hello, I am interested in solving the 1D Kuramoto-Sivashinsky equation for a field u(x,t) with periodic BCs: \\frac{\\partial u}{\\partial t} = - \\frac{\\partial^2 u}{\\partial x^2} - \\frac{\\partial^4 u}{\\partial x^4} - …

---

## [To use the bifuraction kit, how much minimum theory must i know?](https://discourse.julialang.org/t/to-use-the-bifuraction-kit-how-much-minimum-theory-must-i-know/108279)

<div class="topic-metadata">

**Author:** [@Ananya\_Hazarika](https://discourse.julialang.org/u/Ananya_Hazarika)\
**Replies:** 2\
**Last updated:** [January 3, 2024, 1:42pm UTC](https://discourse.julialang.org/t/to-use-the-bifuraction-kit-how-much-minimum-theory-must-i-know/108279 "2024-01-03T13:42:08Z")

</div>

any links references,like books ,concepts? I have downloaded a lot of books but , if you @ChrisRackauckas could give me a more narrowed down approach? Thank you, Regards

---

## [Get path of system image from within Julia?](https://discourse.julialang.org/t/get-path-of-system-image-from-within-julia/108257)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 2\
**Last updated:** [January 3, 2024, 1:29pm UTC](https://discourse.julialang.org/t/get-path-of-system-image-from-within-julia/108257 "2024-01-03T13:29:09Z")

</div>

If I create a custom system image using PackageCompiler, and then start julia using that image like $ julia -Jcustom\_sysimage.so is there a way to get the path to custom\_sysimage.so from within julia? The reason I ask…

---

## [Get the diagonal of a matrix](https://discourse.julialang.org/t/get-the-diagonal-of-a-matrix/108286)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 6\
**Last updated:** [January 3, 2024, 12:09pm UTC](https://discourse.julialang.org/t/get-the-diagonal-of-a-matrix/108286 "2024-01-03T12:09:06Z")

</div>

In matlab, we have d = diag(D) It seems that there is no such function in julia? help?\> diag search: spdiagm blockdiag OrdinalRange disable\_sigint ENDIAN\_BOM dirname isdirpath isdispatchtuple display displaysize displ…

---

## [How to understand thread count as reported by versioninfo()?](https://discourse.julialang.org/t/how-to-understand-thread-count-as-reported-by-versioninfo/108289)

<div class="topic-metadata">

**Author:** [@vnegi10](https://discourse.julialang.org/u/vnegi10)\
**Replies:** 3\
**Last updated:** [January 3, 2024, 11:07am UTC](https://discourse.julialang.org/t/how-to-understand-thread-count-as-reported-by-versioninfo/108289 "2024-01-03T11:07:54Z")

</div>

Before Julia 1.10, number of threads reported by versioninfo() was correct. For example, when started with 8 threads, Julia 1.9.4 shows the following: julia\> versioninfo() Julia Version 1.9.4 Commit 8e5136fa297 (2023-11…

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

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