# General Usage

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

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

**Page:** 541

---

## [Why does findfirst(==(T), ...) on a tuple of typed only constant fold for the first?](https://discourse.julialang.org/t/why-does-findfirst-t-on-a-tuple-of-typed-only-constant-fold-for-the-first/68893)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 2\
**Last updated:** [September 29, 2021, 1:32pm UTC](https://discourse.julialang.org/t/why-does-findfirst-t-on-a-tuple-of-typed-only-constant-fold-for-the-first/68893 "2021-09-29T13:32:52Z")

</div>

Consider: position(::T) where T = findfirst(==(T), (Int, Float64, Char)) You might think this would either constant fold or not. But actually, it constant-folds for the Int inputs but not for Float64 or Char. And if …

---

## [Version problem github actions documenter.jl build](https://discourse.julialang.org/t/version-problem-github-actions-documenter-jl-build/68931)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 0\
**Last updated:** [September 29, 2021, 1:25pm UTC](https://discourse.julialang.org/t/version-problem-github-actions-documenter-jl-build/68931 "2021-09-29T13:25:37Z")

</div>

i have a problem with building docs on gh-actions. locally no problems. I see this log on the runner: Resolving package versions... 51 ERROR: Unsatisfiable requirements detected for package Flux \[587475ba\]: 52 Flux …

---

## [JET.jl type checker does not update module (can Revise.jl help?)](https://discourse.julialang.org/t/jet-jl-type-checker-does-not-update-module-can-revise-jl-help/68929)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 0\
**Last updated:** [September 29, 2021, 12:57pm UTC](https://discourse.julialang.org/t/jet-jl-type-checker-does-not-update-module-can-revise-jl-help/68929 "2021-09-29T12:57:45Z")

</div>

Suppose I have a file test.jl which contains using MyModule. I use the type checker JET.jl with report\_file("test.jl"). The main purpose is to perform type checking of the code in MyModule. However, when I update the cod…

---

## [Is there an easy way to fill with zeros in array concatenation?](https://discourse.julialang.org/t/is-there-an-easy-way-to-fill-with-zeros-in-array-concatenation/68910)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 10\
**Last updated:** [September 29, 2021, 12:53pm UTC](https://discourse.julialang.org/t/is-there-an-easy-way-to-fill-with-zeros-in-array-concatenation/68910 "2021-09-29T12:53:38Z")

</div>

For example, julia\> \[rand(2,2) zeros(2,3) zeros(3,2) rand(3,3)\] 5×5 Matrix{Float64}: 0.717944 0.840054 0.0 0.0 0.0 0.513488 0.62959 0.0 0.0 0.0 0.0 0.0 0.553575 0.129…

---

## [How can I eliminate allocations here?](https://discourse.julialang.org/t/how-can-i-eliminate-allocations-here/68859)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [September 29, 2021, 12:28pm UTC](https://discourse.julialang.org/t/how-can-i-eliminate-allocations-here/68859 "2021-09-29T12:28:15Z")

</div>

How can I eliminate allocations here? I understand I am allocating in shares1 = copy(shares), but where else? function logit(x; min=0, max=1) (max - min) \* (1/(1 + exp(-x))) + min end function \_cessum(x, shares, r)…

---

## [Efficient generation of random number from 2 columns in a dataframe](https://discourse.julialang.org/t/efficient-generation-of-random-number-from-2-columns-in-a-dataframe/68824)

<div class="topic-metadata">

**Author:** [@CompulsoryCoffee](https://discourse.julialang.org/u/CompulsoryCoffee)\
**Replies:** 4\
**Last updated:** [September 29, 2021, 12:07pm UTC](https://discourse.julialang.org/t/efficient-generation-of-random-number-from-2-columns-in-a-dataframe/68824 "2021-09-29T12:07:58Z")

</div>

Hi, If I have a column with the mean and another one with the standard deviation - how to create a new column with this function: rng(m,s) = rand(Normal(m, s), 1) The fastest option is preferred … Thanks!

---

## [Kubernetes-pod-fails-with-crashloopbackoff while deploying using docker image on GCP](https://discourse.julialang.org/t/kubernetes-pod-fails-with-crashloopbackoff-while-deploying-using-docker-image-on-gcp/68912)

<div class="topic-metadata">

**Author:** [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)\
**Replies:** 3\
**Last updated:** [September 29, 2021, 11:15am UTC](https://discourse.julialang.org/t/kubernetes-pod-fails-with-crashloopbackoff-while-deploying-using-docker-image-on-gcp/68912 "2021-09-29T11:15:20Z")

</div>

Hi, I created a docker file for my application: FROM julia:1.6 RUN apt-get update && apt-get install -y gcc ENV JULIA\_PROJECT @. WORKDIR /home ENV VERSION 1 ADD . /home RUN julia deploy/packagecompile.jl EXPOSE 80…

---

## [Stability of system of periodic delay differential equations](https://discourse.julialang.org/t/stability-of-system-of-periodic-delay-differential-equations/68904)

<div class="topic-metadata">

**Author:** [@ANasc](https://discourse.julialang.org/u/ANasc)\
**Replies:** 1\
**Last updated:** [September 29, 2021, 10:49am UTC](https://discourse.julialang.org/t/stability-of-system-of-periodic-delay-differential-equations/68904 "2021-09-29T10:49:40Z")

</div>

Hi All, I want to analyze the stability of a system of delay differential equations. I have tried to dive into some of the literature on this but frankly it’s over my head mathematically. I have tried to implement a pub…

---

## [ModelingToolkit, initial data for second order ODE with state vector](https://discourse.julialang.org/t/modelingtoolkit-initial-data-for-second-order-ode-with-state-vector/68907)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 2\
**Last updated:** [September 29, 2021, 10:16am UTC](https://discourse.julialang.org/t/modelingtoolkit-initial-data-for-second-order-ode-with-state-vector/68907 "2021-09-29T10:16:30Z")

</div>

I don’t get why this doesn’t work: @variables t z\[1:2,1:2\](t) z = collect(z) Dt = Differential(t) eqs = Dt.(Dt.(z\[:\])) .~ 1 u0 = vcat(z\[:\] .=\> 0., Dt.(z\[:\]) .=\> 1.0) tspan = (0.0, 10.0) @named sys = ODESystem(eqs) pr…

---

## [Expression as single fraction in Symbolics.jl](https://discourse.julialang.org/t/expression-as-single-fraction-in-symbolics-jl/68816)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 4\
**Last updated:** [September 28, 2021, 11:04pm UTC](https://discourse.julialang.org/t/expression-as-single-fraction-in-symbolics-jl/68816 "2021-09-28T23:04:32Z")

</div>

I am using Symbolics.jl to automate some tedious mathematical operations in a large expression. I would like to express the result as a single fraction rather than the sum of several fractions. I tried to accomplish this…

---

## [Advice on using unsafe\_wrap to view integers as atomic integers](https://discourse.julialang.org/t/advice-on-using-unsafe-wrap-to-view-integers-as-atomic-integers/67918)

<div class="topic-metadata">

**Author:** [@orenbenkiki](https://discourse.julialang.org/u/orenbenkiki)\
**Replies:** 16\
**Last updated:** [September 28, 2021, 7:45pm UTC](https://discourse.julialang.org/t/advice-on-using-unsafe-wrap-to-view-integers-as-atomic-integers/67918 "2021-09-28T19:45:21Z")

</div>

I’m trying to view the same memory region as a vector of different types of the same size. The goal is to view a (large) vector of integers as a vector of atomic integers (counts), to allow parallel threads to perform at…

---

## [From papers to Julia code: examples wanted](https://discourse.julialang.org/t/from-papers-to-julia-code-examples-wanted/62704)

<div class="topic-metadata">

**Author:** [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Replies:** 10\
**Last updated:** [September 28, 2021, 5:44pm UTC](https://discourse.julialang.org/t/from-papers-to-julia-code-examples-wanted/62704 "2021-09-28T17:44:51Z")

</div>

Ian Weaver Started a very nice discussion in Slack that could use some more community input: We want examples were Julia code matches the paper pseudo code or mathematical specification. Here are some examples people f…

---

## [Is there a direct way in Julia to format a number e.g. 9999999999 as a String object "9,999,999,999" for making it convenient to read?](https://discourse.julialang.org/t/is-there-a-direct-way-in-julia-to-format-a-number-e-g-9999999999-as-a-string-object-9-999-999-999-for-making-it-convenient-to-read/68861)

<div class="topic-metadata">

**Author:** [@shubh\_b](https://discourse.julialang.org/u/shubh_b)\
**Replies:** 3\
**Last updated:** [September 28, 2021, 10:16am UTC](https://discourse.julialang.org/t/is-there-a-direct-way-in-julia-to-format-a-number-e-g-9999999999-as-a-string-object-9-999-999-999-for-making-it-convenient-to-read/68861 "2021-09-28T10:16:45Z")

</div>

Is there any Julia function or a straightforward way that can format a large integer number as a String object in which every 3 digits can become delimited by comma (,) from the end? This thing we can do in Python using…

---

## [Pkg.update() does not update, but Pkg.add() does](https://discourse.julialang.org/t/pkg-update-does-not-update-but-pkg-add-does/68877)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 1\
**Last updated:** [September 28, 2021, 2:05pm UTC](https://discourse.julialang.org/t/pkg-update-does-not-update-but-pkg-add-does/68877 "2021-09-28T14:05:45Z")

</div>

I recently released a patch update of a registered package (say PackageA). The version number increased from 0.3.1 to 0.3.2. On a different computer, I installed PackageB that depends on PackageA. PackageA was not ins…

---

## [FLoops composable way of multithreading nested loops?](https://discourse.julialang.org/t/floops-composable-way-of-multithreading-nested-loops/68832)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 12:23pm UTC](https://discourse.julialang.org/t/floops-composable-way-of-multithreading-nested-loops/68832 "2021-09-28T12:23:04Z")

</div>

I’m writing an algorithm for a discrete time dynamic programming problem in economics. The algorithm involves nested looping over 4 state variables - 2 exogenous, 2 endogenous. The solution to the problem 4 dimensional…

---

## [Is there any package similar to python's decimal in Julia? Where we can use any precision?](https://discourse.julialang.org/t/is-there-any-package-similar-to-pythons-decimal-in-julia-where-we-can-use-any-precision/68834)

<div class="topic-metadata">

**Author:** [@aburousan](https://discourse.julialang.org/u/aburousan)\
**Replies:** 10\
**Last updated:** [September 28, 2021, 12:12pm UTC](https://discourse.julialang.org/t/is-there-any-package-similar-to-pythons-decimal-in-julia-where-we-can-use-any-precision/68834 "2021-09-28T12:12:11Z")

</div>

I have written this piece of code in python. from decimal import \* def pi\_chudn(n): getcontext().prec = n+50 k=0 pi\_chud = 0 while k\<n: pi\_chud+=(((Decimal(-1))\*\*k ) \* (Decimal(mp.factorial(6\*k))…

---

## [Julia function for replacing nothings with default values?](https://discourse.julialang.org/t/julia-function-for-replacing-nothings-with-default-values/68863)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 9:57am UTC](https://discourse.julialang.org/t/julia-function-for-replacing-nothings-with-default-values/68863 "2021-09-28T09:57:33Z")

</div>

Does Julia have a built-in function akin to the following? replace\_nothing(given,default) = given replace\_nothing(::Nothing, default) = default

---

## [Efficiently create large array of structs without allocations](https://discourse.julialang.org/t/efficiently-create-large-array-of-structs-without-allocations/68843)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 5\
**Last updated:** [September 28, 2021, 7:39am UTC](https://discourse.julialang.org/t/efficiently-create-large-array-of-structs-without-allocations/68843 "2021-09-28T07:39:58Z")

</div>

I want to create a very large array of a custom struct type. However, I am finding that the loop that fills the (pre-allocated array) is requiring a large amount of memory allocations and is very slow as a result. I ass…

---

## [Compile Julia using experimental GNU GCC for apple silicon](https://discourse.julialang.org/t/compile-julia-using-experimental-gnu-gcc-for-apple-silicon/59374)

<div class="topic-metadata">

**Author:** [@luis-perez-one](https://discourse.julialang.org/u/luis-perez-one)\
**Replies:** 8\
**Last updated:** [June 3, 2021, 9:29pm UTC](https://discourse.julialang.org/t/compile-julia-using-experimental-gnu-gcc-for-apple-silicon/59374 "2021-06-03T21:29:04Z")

</div>

Hello everyone! This is my first post in the forum. :grinning: I was wondering, have any of you been able to compile Julia using the experimental GCC - Fortan compiler from Iain Sanode for apple silicon? I just pulled …

---

## [How to ccall struct array from C?](https://discourse.julialang.org/t/how-to-ccall-struct-array-from-c/68805)

<div class="topic-metadata">

**Author:** [@kimmolinna](https://discourse.julialang.org/u/kimmolinna)\
**Replies:** 4\
**Last updated:** [September 28, 2021, 3:43am UTC](https://discourse.julialang.org/t/how-to-ccall-struct-array-from-c/68805 "2021-09-28T03:43:11Z")

</div>

I would like read call directly duckdb c-api, but I have some difficulties with structs. I try to do the following c-code in Julia. #include "duckdb.h" #include \<stdio.h\> int main() { duckdb\_database db = NULL; duckd…

---

## [Taking gradients in Julia](https://discourse.julialang.org/t/taking-gradients-in-julia/68731)

<div class="topic-metadata">

**Author:** [@ZHEN\_LIN](https://discourse.julialang.org/u/ZHEN_LIN)\
**Replies:** 7\
**Last updated:** [September 28, 2021, 1:26am UTC](https://discourse.julialang.org/t/taking-gradients-in-julia/68731 "2021-09-28T01:26:55Z")

</div>

I’m looking for a fast package that can take gradients of functions I write in Julia. Similar to the autograd package for Python. It seems that there are a few different options such as Zygote, ForwardDiff.jl, ReverseDi…

---

## [Choosing the number of worker processes](https://discourse.julialang.org/t/choosing-the-number-of-worker-processes/63389)

<div class="topic-metadata">

**Author:** [@jzr](https://discourse.julialang.org/u/jzr)\
**Replies:** 6\
**Last updated:** [September 27, 2021, 11:08pm UTC](https://discourse.julialang.org/t/choosing-the-number-of-worker-processes/63389 "2021-09-27T23:08:49Z")

</div>

I have a job that needs to run in multiple processors. How should I decide what n should be in addprocs(n)? I assume the right number will depend on the tasks and the number of cores and RAM. Is there a way to automate …

---

## [Number in LatexStrings](https://discourse.julialang.org/t/number-in-latexstrings/68840)

<div class="topic-metadata">

**Author:** [@Liwei17](https://discourse.julialang.org/u/Liwei17)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 10:29pm UTC](https://discourse.julialang.org/t/number-in-latexstrings/68840 "2021-09-27T22:29:39Z")

</div>

I want to show something like “ \\sigma = NUMBER ” in the legend of the plot. How can I manage to do that? Thanks!

---

## [How to install CO2System.jl package](https://discourse.julialang.org/t/how-to-install-co2system-jl-package/68817)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 9:39pm UTC](https://discourse.julialang.org/t/how-to-install-co2system-jl-package/68817 "2021-09-27T21:39:17Z")

</div>

The package is located here: https://github.com/mvdh7/CO2System.jl. According to the installation instructions, I should install the CO2System package as below: pkg\> add https://github.com/mvdh7/CO2System.jl My questi…

---

## [Using a closure with mutable captured values inside an @distributed loop](https://discourse.julialang.org/t/using-a-closure-with-mutable-captured-values-inside-an-distributed-loop/68818)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 9:02pm UTC](https://discourse.julialang.org/t/using-a-closure-with-mutable-captured-values-inside-an-distributed-loop/68818 "2021-09-27T21:02:59Z")

</div>

The Julia manual says the following about the @distributed macro: Any variables used inside the parallel loop will be copied and broadcast to each process. My question is: Does this also apply to functions and closur…

---

## [Array of hourly dates](https://discourse.julialang.org/t/array-of-hourly-dates/68827)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 7:19pm UTC](https://discourse.julialang.org/t/array-of-hourly-dates/68827 "2021-09-27T19:19:38Z")

</div>

Hello! I’m trying to use the package Dates to create an array of dates, with the granularity of one hour. For example, I’d like to create an array with all the hours from January 10 to January 20. Any ideas on how I can…

---

## [Reading in multiple matrices of different dimensions from .txt file](https://discourse.julialang.org/t/reading-in-multiple-matrices-of-different-dimensions-from-txt-file/68796)

<div class="topic-metadata">

**Author:** [@conorhassan](https://discourse.julialang.org/u/conorhassan)\
**Replies:** 6\
**Last updated:** [September 27, 2021, 7:05pm UTC](https://discourse.julialang.org/t/reading-in-multiple-matrices-of-different-dimensions-from-txt-file/68796 "2021-09-27T19:05:47Z")

</div>

Hi all, I have a .txt file containing information for 10 matrices of different dimensions. Each row of the .txt file corresponds to a row of a matrix, with whitespace distinguishing the elements. The matrices are seper…

---

## [Using inconsistency between Pluto and REPL with dev Package](https://discourse.julialang.org/t/using-inconsistency-between-pluto-and-repl-with-dev-package/68828)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 1\
**Last updated:** [September 27, 2021, 7:04pm UTC](https://discourse.julialang.org/t/using-inconsistency-between-pluto-and-repl-with-dev-package/68828 "2021-09-27T19:04:55Z")

</div>

I have a Package “Foo” I have developed in .julia\\dev. I just updated to Julia version 1.6.3 in Win10. When I updated to 1.6.3 I updated the package “\] update Foo” and then in the REPL when I type ‘using Foo’ the comma…

---

## [Symbolics.jl: Speed of derivative computations vs. SymEngine.jl](https://discourse.julialang.org/t/symbolics-jl-speed-of-derivative-computations-vs-symengine-jl/68803)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 6:24pm UTC](https://discourse.julialang.org/t/symbolics-jl-speed-of-derivative-computations-vs-symengine-jl/68803 "2021-09-27T18:24:24Z")

</div>

I benchmarked some derivative computations using Symbolics.jl, SymEngine.jl, and SymPy.jl. As expected, SymPy.jl was the slowest solution in my case. However, SymEngine.jl was significantly faster than Symbolics.jl. Here…

---

## [How to retrieve the edge list from a Dict reprepresenting a tree data structure](https://discourse.julialang.org/t/how-to-retrieve-the-edge-list-from-a-dict-reprepresenting-a-tree-data-structure/68802)

<div class="topic-metadata">

**Author:** [@empet](https://discourse.julialang.org/u/empet)\
**Replies:** 6\
**Last updated:** [September 27, 2021, 5:56pm UTC](https://discourse.julialang.org/t/how-to-retrieve-the-edge-list-from-a-dict-reprepresenting-a-tree-data-structure/68802 "2021-09-27T17:56:29Z")

</div>

I’m reading a tree data structure fron a json file, and I need to retrieve the vector of edge tuples, (parent, child), to define a LightGraphs.SimpleDiGraph and get the node positions via NetworkLayout.Buchheim layou…

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

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