# General Usage

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

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

**Page:** 173

---

## [Avoid array duplication](https://discourse.julialang.org/t/avoid-array-duplication/113879)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 5\
**Last updated:** [May 6, 2024, 4:17am UTC](https://discourse.julialang.org/t/avoid-array-duplication/113879 "2024-05-06T04:17:36Z")

</div>

I have a data structure in Julia (CSR matrix, essentially). The same data structure is used in a C++ library that I use from Julia. The question is “how do I avoid the penalty for copying data”? Pass a Julia array to …

---

## [Using Julia on CoCalc With a Compute Server - William A. Stein](https://discourse.julialang.org/t/using-julia-on-cocalc-with-a-compute-server-william-a-stein/113874)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 0\
**Last updated:** [May 5, 2024, 8:44pm UTC](https://discourse.julialang.org/t/using-julia-on-cocalc-with-a-compute-server-william-a-stein/113874 "2024-05-05T20:44:08Z")

</div>

William A. Stein demonstrates Julia on a CoCalc Compute Server: If you’re interested in this, please like the video. They’re thinking about sponsoring JuliaCon.

---

## [Can I use a closure, and if yes how?](https://discourse.julialang.org/t/can-i-use-a-closure-and-if-yes-how/113857)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [May 5, 2024, 6:15pm UTC](https://discourse.julialang.org/t/can-i-use-a-closure-and-if-yes-how/113857 "2024-05-05T18:15:05Z")

</div>

I have the following code: using ControlPlots using KiteModels, KitePodModels, KiteUtils set = deepcopy(se()) kcu::KCU = KCU(set) kps4::KPS4 = KPS4(kcu) include("../examples/plot2d.jl") reltime = 0.0 integrator = Kit…

---

## [Opening symbol from a C++ dynamic library](https://discourse.julialang.org/t/opening-symbol-from-a-c-dynamic-library/113866)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 3\
**Last updated:** [May 5, 2024, 3:56pm UTC](https://discourse.julialang.org/t/opening-symbol-from-a-c-dynamic-library/113866 "2024-05-05T15:56:44Z")

</div>

I do not have much experience with building C++ libraries. This may be a silly question. The library is built as follows: shell\> g++ -O3 -march=native -fPIC -shared -fopenmp ECL-GC\_12-lib.cpp -o ecl-gc.so I can see th…

---

## [There was a problem with ForwardDiff-based Optimization when re-executing the code](https://discourse.julialang.org/t/there-was-a-problem-with-forwarddiff-based-optimization-when-re-executing-the-code/113682)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 13\
**Last updated:** [May 5, 2024, 3:10pm UTC](https://discourse.julialang.org/t/there-was-a-problem-with-forwarddiff-based-optimization-when-re-executing-the-code/113682 "2024-05-05T15:10:49Z")

</div>

I’m using Optimization.jl to optimize some parameters of ODEProblem, where AutoForwardDiff is used for adtype, when the code is executed for the first time, the program does not show any errors, but when I execute the pr…

---

## [Why is \`getindex\` slower the second time in a vector of vectors?](https://discourse.julialang.org/t/why-is-getindex-slower-the-second-time-in-a-vector-of-vectors/113819)

<div class="topic-metadata">

**Author:** [@alex180500](https://discourse.julialang.org/u/alex180500)\
**Replies:** 7\
**Last updated:** [May 5, 2024, 1:56pm UTC](https://discourse.julialang.org/t/why-is-getindex-slower-the-second-time-in-a-vector-of-vectors/113819 "2024-05-05T13:56:15Z")

</div>

Why is in this function calling the getindex method the second time slower? This function (the smallest working example I could make) is a snippet of a bigger project I’m making on agent based models where I choose a ra…

---

## [Filter in function docstrings?](https://discourse.julialang.org/t/filter-in-function-docstrings/113795)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 2\
**Last updated:** [May 5, 2024, 8:51am UTC](https://discourse.julialang.org/t/filter-in-function-docstrings/113795 "2024-05-05T08:51:57Z")

</div>

I’m confused about filtering in docstrings. I know that I can use them in the markdown files of Documenter. But can they be used in regular function docstrings (those embedded in the code)? One thing that is confusing m…

---

## [How to detect whether the build (compiler options) is a production build](https://discourse.julialang.org/t/how-to-detect-whether-the-build-compiler-options-is-a-production-build/113827)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 3\
**Last updated:** [May 5, 2024, 6:35am UTC](https://discourse.julialang.org/t/how-to-detect-whether-the-build-compiler-options-is-a-production-build/113827 "2024-05-05T06:35:36Z")

</div>

Enabling code coverage changes how Julia code is compiled and executed. In particular, code coverage may cause allocations in code that would otherwise be constant-folded: On the other hand, it’s sometimes good to hav…

---

## [How to execute additional code before runtests.jl?](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [May 5, 2024, 6:11am UTC](https://discourse.julialang.org/t/how-to-execute-additional-code-before-runtests-jl/113854 "2024-05-05T06:11:42Z")

</div>

I’m trying to solve How to detect whether the build (compiler options) is a production build. I think the right solution is to introduce a global boolean constant whose value would be determined by the user (most often C…

---

## [Cannot install PyCall](https://discourse.julialang.org/t/cannot-install-pycall/109256)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 7\
**Last updated:** [May 5, 2024, 1:23am UTC](https://discourse.julialang.org/t/cannot-install-pycall/109256 "2024-05-05T01:23:47Z")

</div>

It is the first time I cannot install a package by the standard pkg way. I am using vscode and windows 10. I need this package because it is invoked in another package which I want to use. What is the problem? (@v1.10…

---

## [Get the actual type from an Expr representing a type](https://discourse.julialang.org/t/get-the-actual-type-from-an-expr-representing-a-type/113848)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 2\
**Last updated:** [May 4, 2024, 11:42pm UTC](https://discourse.julialang.org/t/get-the-actual-type-from-an-expr-representing-a-type/113848 "2024-05-04T23:42:50Z")

</div>

I think this may be the question being asked here, but it wasn’t resolved. I am writing a macro that manipulates the signature of a function. I want to know if an argument is annotated with a subtype of a type owned by …

---

## [Announcing our 2024 GSoC & JSoC Fellows!](https://discourse.julialang.org/t/announcing-our-2024-gsoc-jsoc-fellows/113842)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 0\
**Last updated:** [May 4, 2024, 5:32pm UTC](https://discourse.julialang.org/t/announcing-our-2024-gsoc-jsoc-fellows/113842 "2024-05-04T17:32:55Z")

</div>

Hi folks! We’ve written up a little blog post for the Julia website sharing about the new projects for this year’s Google Summer of Code & Julia Summer of Code cohorts! Follow the link to check them out! A huge congratu…

---

## [Custom optimized hash tables with UInt64 keys, lower level than Dict for ultra speed](https://discourse.julialang.org/t/custom-optimized-hash-tables-with-uint64-keys-lower-level-than-dict-for-ultra-speed/113831)

<div class="topic-metadata">

**Author:** [@0x0f0f0f](https://discourse.julialang.org/u/0x0f0f0f)\
**Replies:** 5\
**Last updated:** [May 4, 2024, 2:40pm UTC](https://discourse.julialang.org/t/custom-optimized-hash-tables-with-uint64-keys-lower-level-than-dict-for-ultra-speed/113831 "2024-05-04T14:40:57Z")

</div>

In Metatheory.jl we have e-graphs, which are basically made of some Dicts. We are encountering some performance bottlenecks because of the implementation of Dict, and we realized that optimized data structures could go a…

---

## [Equivalent to pipx (install Julia apps)](https://discourse.julialang.org/t/equivalent-to-pipx-install-julia-apps/113826)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 5\
**Last updated:** [May 4, 2024, 12:02pm UTC](https://discourse.julialang.org/t/equivalent-to-pipx-install-julia-apps/113826 "2024-05-04T12:02:05Z")

</div>

Is there an equivalent to pipx for Julia apps? pipx makes it so easy to install Python apps, mainly intended for console apps, but also works with gui apps. Example: pipx install mnemosyne-proj on Ubuntu installs the…

---

## [Error updating Julia to 1.10.3 with UpdateJulia on mac?](https://discourse.julialang.org/t/error-updating-julia-to-1-10-3-with-updatejulia-on-mac/113703)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 12\
**Last updated:** [May 4, 2024, 12:37am UTC](https://discourse.julialang.org/t/error-updating-julia-to-1-10-3-with-updatejulia-on-mac/113703 "2024-05-04T00:37:47Z")

</div>

Hi I’m currently using Julia Version 1.10.2 on a macOS (arm64) Apple M1 Max I get the following error when trying to update julia to 1.10.3 julia\> using UpdateJulia julia\> update\_julia() ERROR: No valid download for …

---

## [Jldoctest: number of elements printed for array](https://discourse.julialang.org/t/jldoctest-number-of-elements-printed-for-array/113794)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 12\
**Last updated:** [May 4, 2024, 12:06am UTC](https://discourse.julialang.org/t/jldoctest-number-of-elements-printed-for-array/113794 "2024-05-04T00:06:21Z")

</div>

In a docstring like: \`\`\`jldoctest julia\> x = rand(1000) 1000-element Vector{Float64}: 0.9193285028224774 0.35444797029663266 0.1201916693868853 0.35371426411293694 0.11668489865605236 0.6506991967008628 ⋮ 0.5180…

---

## [Collapse duplicate rows in Julia matrix](https://discourse.julialang.org/t/collapse-duplicate-rows-in-julia-matrix/113817)

<div class="topic-metadata">

**Author:** [@Santiago\_Lopez](https://discourse.julialang.org/u/Santiago_Lopez)\
**Replies:** 2\
**Last updated:** [May 3, 2024, 9:45pm UTC](https://discourse.julialang.org/t/collapse-duplicate-rows-in-julia-matrix/113817 "2024-05-03T21:45:21Z")

</div>

I have a matrix U = vcat(s, e, p) of the form 3167×2 Matrix{Int64}: 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 3 1 3 1 3 3 2 3 2 3 3 ⋮ 962 5 962 5 962 5…

---

## [Finding functions](https://discourse.julialang.org/t/finding-functions/105285)

<div class="topic-metadata">

**Author:** [@panos.asproulis](https://discourse.julialang.org/u/panos.asproulis)\
**Replies:** 13\
**Last updated:** [May 3, 2024, 9:29pm UTC](https://discourse.julialang.org/t/finding-functions/105285 "2024-05-03T21:29:08Z")

</div>

One issue I have with Julia is remembering the name of functions and what they do. In a typical OOP language and IDE/editor typing the name of an object and then the dot character a pop-up window will produce a list of a…

---

## [Why does \`let\` allow comma-separated assignments?](https://discourse.julialang.org/t/why-does-let-allow-comma-separated-assignments/113812)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 7\
**Last updated:** [May 3, 2024, 9:06pm UTC](https://discourse.julialang.org/t/why-does-let-allow-comma-separated-assignments/113812 "2024-05-03T21:06:46Z")

</div>

This is something I’ve always wondered… Why does a let block allow comma-separated assignments? let x = 1, y = 2, z = 3 (x, y, z) end As far as I can tell, this is completely identical to let x = 1; y = 2; z = 3 …

---

## [Converting Float32 values back to Float64 without introducing nonzero digits at the end?](https://discourse.julialang.org/t/converting-float32-values-back-to-float64-without-introducing-nonzero-digits-at-the-end/113810)

<div class="topic-metadata">

**Author:** [@Norman](https://discourse.julialang.org/u/Norman)\
**Replies:** 2\
**Last updated:** [May 3, 2024, 6:59pm UTC](https://discourse.julialang.org/t/converting-float32-values-back-to-float64-without-introducing-nonzero-digits-at-the-end/113810 "2024-05-03T18:59:17Z")

</div>

I hope this question is not silly. When converting a Float32 value back to Float64, I get something like this: julia\> Float64(Float32(0.1)) 0.10000000149011612 Is there a way to obtain exactly 0.1 without having the no…

---

## [Parsing Julia code to separate symbols based on scoping and create a symbol table](https://discourse.julialang.org/t/parsing-julia-code-to-separate-symbols-based-on-scoping-and-create-a-symbol-table/113809)

<div class="topic-metadata">

**Author:** [@Akhil\_Akkapelli](https://discourse.julialang.org/u/Akhil_Akkapelli)\
**Replies:** 1\
**Last updated:** [May 3, 2024, 7:00pm UTC](https://discourse.julialang.org/t/parsing-julia-code-to-separate-symbols-based-on-scoping-and-create-a-symbol-table/113809 "2024-05-03T19:00:39Z")

</div>

I have a quote block in Julia containing functions, modules, and etc. Assuming that quote block is in Main module and Main module does not have these symbols with same names. I want to separate the symbols based on their…

---

## [Do you use PkgTemplates for personal projects?](https://discourse.julialang.org/t/do-you-use-pkgtemplates-for-personal-projects/113780)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 3\
**Last updated:** [May 3, 2024, 6:30pm UTC](https://discourse.julialang.org/t/do-you-use-pkgtemplates-for-personal-projects/113780 "2024-05-03T18:30:20Z")

</div>

For personal projects which likely won’t become a published package, do you use Pkg.generate or the full-fledged PkgTemplates.jl? The latter has nice things like setting up the CI, but I’m not sure if I should use it for…

---

## [How to exit from loop on keyboard button pressing?](https://discourse.julialang.org/t/how-to-exit-from-loop-on-keyboard-button-pressing/113808)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 0\
**Last updated:** [May 3, 2024, 5:59pm UTC](https://discourse.julialang.org/t/how-to-exit-from-loop-on-keyboard-button-pressing/113808 "2024-05-03T17:59:27Z")

</div>

Hello, how to exit from loop on keyboard button pressing? I see two ways: catch InterruptException or this: function main\_loop() println("Press 'Enter' to stop.") task = Threads.@spawn readline(stdin) while true …

---

## [Plots.jl package ceases to work](https://discourse.julialang.org/t/plots-jl-package-ceases-to-work/113798)

<div class="topic-metadata">

**Author:** [@torein](https://discourse.julialang.org/u/torein)\
**Replies:** 9\
**Last updated:** [May 3, 2024, 5:36pm UTC](https://discourse.julialang.org/t/plots-jl-package-ceases-to-work/113798 "2024-05-03T17:36:56Z")

</div>

Hi there, I have been using Julia 1.82 on Windows 10 for nearly two years. Up til now, the Plots.jl package has funcioned very well. Suddenly, however, the package fails to work. Whenever I run a code that includes…

---

## [Error: Installation of Plots](https://discourse.julialang.org/t/error-installation-of-plots/100318)

<div class="topic-metadata">

**Author:** [@ilex](https://discourse.julialang.org/u/ilex)\
**Replies:** 1\
**Last updated:** [May 3, 2024, 4:38pm UTC](https://discourse.julialang.org/t/error-installation-of-plots/100318 "2024-05-03T16:38:28Z")

</div>

Trying to install Plots following error occures: julia\> import Pkg; julia\> Pkg.add(“Plots”) Updating registry at C:\\Users\\angel.naya-geiger\\Juliawin\\userdata\\.julia\\registries\\General.toml Resolving package versions…

---

## [Comparison between Loops and Vectorization in Julia](https://discourse.julialang.org/t/comparison-between-loops-and-vectorization-in-julia/113724)

<div class="topic-metadata">

**Author:** [@jackmarry](https://discourse.julialang.org/u/jackmarry)\
**Replies:** 3\
**Last updated:** [May 3, 2024, 1:00pm UTC](https://discourse.julialang.org/t/comparison-between-loops-and-vectorization-in-julia/113724 "2024-05-03T13:00:06Z")

</div>

Is Julia’s loop as fast as the code written in vectorized form?

---

## [Type-stable alternatives to Iterators.product?](https://discourse.julialang.org/t/type-stable-alternatives-to-iterators-product/113790)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 2\
**Last updated:** [May 3, 2024, 12:50pm UTC](https://discourse.julialang.org/t/type-stable-alternatives-to-iterators-product/113790 "2024-05-03T12:50:19Z")

</div>

I’m dealing with a combinatorial problem. Given N vectors of integers of varied lengths, I want to find all possible ways to select one integer from each vector. Here’s my code, which is unfortunately not type-stable: j…

---

## [Sample without replacement.. and without StatsBase or shuffle](https://discourse.julialang.org/t/sample-without-replacement-and-without-statsbase-or-shuffle/113725)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 12\
**Last updated:** [May 3, 2024, 7:58am UTC](https://discourse.julialang.org/t/sample-without-replacement-and-without-statsbase-or-shuffle/113725 "2024-05-03T07:58:08Z")

</div>

Hi, is there a way to sample 3 ids from 1:10 without replacement but also without using StatsBase (or any other package) or shuffling/randperm the whole array (in my case it could be relatively big) ?

---

## [How to check value of exit\_on\_sigint programmatically?](https://discourse.julialang.org/t/how-to-check-value-of-exit-on-sigint-programmatically/113776)

<div class="topic-metadata">

**Author:** [@vettert](https://discourse.julialang.org/u/vettert)\
**Replies:** 0\
**Last updated:** [May 3, 2024, 7:30am UTC](https://discourse.julialang.org/t/how-to-check-value-of-exit-on-sigint-programmatically/113776 "2024-05-03T07:30:38Z")

</div>

The Base.exit\_on\_sigint(bool) function allows to set whether Julia terminates upon receiving a sigint signal. Now, I am wondering whether I can get the value somehow programmatically? Is there a way? The docstring doesn’…

---

## [Some problem when optimizing the ODEProblem parameters](https://discourse.julialang.org/t/some-problem-when-optimizing-the-odeproblem-parameters/113746)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 4\
**Last updated:** [May 3, 2024, 4:06am UTC](https://discourse.julialang.org/t/some-problem-when-optimizing-the-odeproblem-parameters/113746 "2024-05-03T04:06:03Z")

</div>

Use ModelingToolkit.jl to build ODEproblem and Optimization respectively to optimize the parameters of ODEproblem with the following code: using ModelingToolkit, Optimization, ComponentArrays using ModelingToolkit: t\_no…

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

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