# General Usage

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

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

**Page:** 555

---

## [Solving difference equation: Part 2](https://discourse.julialang.org/t/solving-difference-equation-part-2/67057)

<div class="topic-metadata">

**Author:** [@MathGuy](https://discourse.julialang.org/u/MathGuy)\
**Replies:** 4\
**Last updated:** [August 29, 2021, 8:43am UTC](https://discourse.julialang.org/t/solving-difference-equation-part-2/67057 "2021-08-29T08:43:02Z")

</div>

In my previous post I was trying to get to reach a conclusion whether I can get more speed in solving a system of difference equation (basically a discrete dynamical system) through a hand-written code. I got useful sug…

---

## [Switch Julia version](https://discourse.julialang.org/t/switch-julia-version/67100)

<div class="topic-metadata">

**Author:** [@Hannah\_Rocio\_Santa\_C](https://discourse.julialang.org/u/Hannah_Rocio_Santa_C)\
**Replies:** 9\
**Last updated:** [August 29, 2021, 3:38am UTC](https://discourse.julialang.org/t/switch-julia-version/67100 "2021-08-29T03:38:20Z")

</div>

Hello, I’ve been using Julia 1.0, but have now run into a package that requires 1.1 (Cxx.jl), so I downloaded it, but don’t know how to set up Julia Pro to use it. I would like to still be able to use version 1.0, so I …

---

## [Gtk Combo Box](https://discourse.julialang.org/t/gtk-combo-box/67230)

<div class="topic-metadata">

**Author:** [@SergeantMike67](https://discourse.julialang.org/u/SergeantMike67)\
**Replies:** 0\
**Last updated:** [August 28, 2021, 3:53pm UTC](https://discourse.julialang.org/t/gtk-combo-box/67230 "2021-08-28T15:53:46Z")

</div>

Throwing in the towel. I am trying to make a data entry form for a MariaDB database. I designed the form in Glade and used Gtk.jl:GtkBuilder to create the form through Julia. What I want to have a is combo box that is…

---

## [Allocations of @threads](https://discourse.julialang.org/t/allocations-of-threads/67047)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 10\
**Last updated:** [August 28, 2021, 10:27pm UTC](https://discourse.julialang.org/t/allocations-of-threads/67047 "2021-08-28T22:27:10Z")

</div>

In simulations, one usually has a external loop which runs over time steps, and inner loops that compute, for example, interactions between particles. These last loops are parallelized. Therefore, one has something as: j…

---

## [Multithreading balancing](https://discourse.julialang.org/t/multithreading-balancing/67220)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 6\
**Last updated:** [August 28, 2021, 10:13pm UTC](https://discourse.julialang.org/t/multithreading-balancing/67220 "2021-08-28T22:13:52Z")

</div>

Consider the following scenario (in local scope): function .... @threads for i ∈ 1:128 y\[i\] = dosomethingexpensive( x\[i\] ) end end Say I’m running this on a machine with 32 physical cores. Then often,…

---

## [Mathlink.jl installation issue on Windows 10](https://discourse.julialang.org/t/mathlink-jl-installation-issue-on-windows-10/67217)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 2\
**Last updated:** [August 28, 2021, 7:56pm UTC](https://discourse.julialang.org/t/mathlink-jl-installation-issue-on-windows-10/67217 "2021-08-28T19:56:25Z")

</div>

Dear All, I am trying to install MathLink.jl on Windows 10. I have a full version of Mathematica 12.3, but I do not think it contains any “libML64.dll/ libML32.dll” file as mentioned in ReadMe. The closest is ml64i4.dll …

---

## [foo(T) where T # in Vector{DataType}](https://discourse.julialang.org/t/foo-t-where-t-in-vector-datatype/67243)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 3\
**Last updated:** [August 28, 2021, 7:49pm UTC](https://discourse.julialang.org/t/foo-t-where-t-in-vector-datatype/67243 "2021-08-28T19:49:46Z")

</div>

Hellow, how can i write a function like this: vector\_data\_type = \[ Int64, Int32, Int16, \] foo(T) where T # in vector\_data\_type

---

## [How to use vertical GtkScale in GtkGrid with Gtk.jl](https://discourse.julialang.org/t/how-to-use-vertical-gtkscale-in-gtkgrid-with-gtk-jl/46752)

<div class="topic-metadata">

**Author:** [@kogad](https://discourse.julialang.org/u/kogad)\
**Replies:** 3\
**Last updated:** [August 28, 2021, 4:28pm UTC](https://discourse.julialang.org/t/how-to-use-vertical-gtkscale-in-gtkgrid-with-gtk-jl/46752 "2021-08-28T16:28:20Z")

</div>

Hi. I am trying to use a vertical slider (GtkScale) in a grid , but this code does not work well. using Gtk win = GtkWindow() c = GtkScale(false, -1:0.1:1) oc = GtkOrientable(c) GAccessor.orientation(oc, 1) b1 = GtkBu…

---

## [Solve ODE with many different initial conditions](https://discourse.julialang.org/t/solve-ode-with-many-different-initial-conditions/66384)

<div class="topic-metadata">

**Author:** [@hongchengni](https://discourse.julialang.org/u/hongchengni)\
**Replies:** 4\
**Last updated:** [August 28, 2021, 3:41pm UTC](https://discourse.julialang.org/t/solve-ode-with-many-different-initial-conditions/66384 "2021-08-28T15:41:20Z")

</div>

Hello friends, I have an ODE to solve with many different initial conditions varying in a nested loop. In my old code, I simply define the ODEProblem within the inner loop, which is simplest but slow. I suppose there ar…

---

## [Problem for adding new package:opening file](https://discourse.julialang.org/t/problem-for-adding-new-package-opening-file/67211)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 0\
**Last updated:** [August 28, 2021, 9:43am UTC](https://discourse.julialang.org/t/problem-for-adding-new-package-opening-file/67211 "2021-08-28T09:43:42Z")

</div>

I want to add a new package.But it shows me such error: (@JuliaPro\_v1.5.4-1) pkg\> add DecisionTree Updating registry at \`C:\\Users\\zlq\\.julia\\registries\\General\` ERROR: SystemError: opening file "C:\\\\Users\\\\zlq\\\\AppD…

---

## [Is preallocation possible for repeated calculation of trajectory of a discrete model (DynamicalSystems.jl)?](https://discourse.julialang.org/t/is-preallocation-possible-for-repeated-calculation-of-trajectory-of-a-discrete-model-dynamicalsystems-jl/67147)

<div class="topic-metadata">

**Author:** [@MathGuy](https://discourse.julialang.org/u/MathGuy)\
**Replies:** 3\
**Last updated:** [August 28, 2021, 6:26am UTC](https://discourse.julialang.org/t/is-preallocation-possible-for-repeated-calculation-of-trajectory-of-a-discrete-model-dynamicalsystems-jl/67147 "2021-08-28T06:26:58Z")

</div>

I need to analyze the following discrete model in r-k parametric space, function test\_difference\_eq(x,par,n) r, k = par a = 5.0; mu = 0.5; d = 0.2; dx = x\[1\]\*exp(r\*(1-x\[1\]/k)-x\[2\]/(a+x\[1\]^2)) dy = x\[2\]\*exp(m…

---

## [First n elements of array with Base.first](https://discourse.julialang.org/t/first-n-elements-of-array-with-base-first/28512)

<div class="topic-metadata">

**Author:** [@milesf](https://discourse.julialang.org/u/milesf)\
**Replies:** 6\
**Last updated:** [August 28, 2021, 4:35am UTC](https://discourse.julialang.org/t/first-n-elements-of-array-with-base-first/28512 "2021-08-28T04:35:02Z")

</div>

Is there a built-in way to get the first n elements of an array, even if n exceeds the length of the array? This function demonstrates the desired behavior: function first\_n(a, n) n = min(n, length(a)) a\[1:n\] e…

---

## [Are exceptions in Julia "Zero Cost"](https://discourse.julialang.org/t/are-exceptions-in-julia-zero-cost/38405)

<div class="topic-metadata">

**Author:** [@risingganymede](https://discourse.julialang.org/u/risingganymede)\
**Replies:** 12\
**Last updated:** [August 28, 2021, 1:02am UTC](https://discourse.julialang.org/t/are-exceptions-in-julia-zero-cost/38405 "2021-08-28T01:02:39Z")

</div>

In C++, there is no performance penalty for writing exception handlers provided that exceptions aren’t actually thrown (which should be “rare”). I was wondering if handling exceptions in Julia adds any overhead in the no…

---

## [MethodError: no method matching getindex(::Nothing, ::String)](https://discourse.julialang.org/t/methoderror-no-method-matching-getindex-nothing-string/67080)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 3\
**Last updated:** [August 28, 2021, 12:33am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-getindex-nothing-string/67080 "2021-08-28T00:33:10Z")

</div>

Hi, I’m trying to do an iteration, where I use a dictionary that gives me an array with values (“players”) and an array with weights (“weights”) with the same size, to make a sample. When I do it outside of iteration it …

---

## [Is resize! always in-place?](https://discourse.julialang.org/t/is-resize-always-in-place/67196)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 6\
**Last updated:** [August 27, 2021, 11:27pm UTC](https://discourse.julialang.org/t/is-resize-always-in-place/67196 "2021-08-27T23:27:12Z")

</div>

Following up from Implications of resize! If I have a vector of Float64, e.g. a = \[0.1, 0.2, 0.3\] and I call b = resize!(a, N) for some integer N, is there any sort of guarantee that a===b? That is, is it safe to si…

---

## [Finding column indices of nonzero elements in a sparse matrix](https://discourse.julialang.org/t/finding-column-indices-of-nonzero-elements-in-a-sparse-matrix/67063)

<div class="topic-metadata">

**Author:** [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Replies:** 5\
**Last updated:** [August 27, 2021, 9:00pm UTC](https://discourse.julialang.org/t/finding-column-indices-of-nonzero-elements-in-a-sparse-matrix/67063 "2021-08-27T21:00:10Z")

</div>

Is there any julia way to find column indices of nonzero elements in a sparse matrix ? I mean something that nzrange(A,j) does, but here j is the row index

---

## [DataFramesMeta computing weighted median within @by](https://discourse.julialang.org/t/dataframesmeta-computing-weighted-median-within-by/67111)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 3\
**Last updated:** [August 27, 2021, 8:39pm UTC](https://discourse.julialang.org/t/dataframesmeta-computing-weighted-median-within-by/67111 "2021-08-27T20:39:12Z")

</div>

I’m struggling to figure this out. I have some data that look like this: using DataFrames using DataFramesMeta using StatsBase df = DataFrame(a=\[1,1,2,2,3,3,4,4,5,5,6,6\], b=rand(vcat(1:3, missing), 12), c=rand(10:50, 1…

---

## [Get all combinations in a range](https://discourse.julialang.org/t/get-all-combinations-in-a-range/67108)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 1\
**Last updated:** [August 27, 2021, 4:05pm UTC](https://discourse.julialang.org/t/get-all-combinations-in-a-range/67108 "2021-08-27T16:05:50Z")

</div>

Hi, I’m trying to get the following algorithm (done with Python) but in Julia: from itertools import product coins = \[2, 5, 10, 20, 50, 100\] no\_ways = 0 bunch\_of\_coins = product(\*\[range(0, 201, i) for i in coins\]) for…

---

## [Julia implementation of IDL's rebin?](https://discourse.julialang.org/t/julia-implementation-of-idls-rebin/67098)

<div class="topic-metadata">

**Author:** [@sbrisard](https://discourse.julialang.org/u/sbrisard)\
**Replies:** 0\
**Last updated:** [August 27, 2021, 1:08pm UTC](https://discourse.julialang.org/t/julia-implementation-of-idls-rebin/67098 "2021-08-27T13:08:25Z")

</div>

Hello, I am looking for the Julia equivalent of IDL’s rebin function. It basically applies a reduction function f to “macro-cells” of an array. For example, a (M₁ \* N₁, M₂ \* N₂, …, Mₚ \* Nₚ) array, x would be transformed…

---

## [Creating an iterative structure](https://discourse.julialang.org/t/creating-an-iterative-structure/67088)

<div class="topic-metadata">

**Author:** [@Rajesh\_Nakka](https://discourse.julialang.org/u/Rajesh_Nakka)\
**Replies:** 8\
**Last updated:** [August 27, 2021, 9:56am UTC](https://discourse.julialang.org/t/creating-an-iterative-structure/67088 "2021-08-27T09:56:50Z")

</div>

Given, struct Point x::Float64 y::Float64 z::Float64 end p1 = Point(1.0, 0.0, 0.0) p2 = Point(1.0, 1.0, 0.0) p3 = Point(1.0, 0.0, 1.0) I want to define another iterative structure Points similar to Julia Ar…

---

## [Loading packages in a parallel thread](https://discourse.julialang.org/t/loading-packages-in-a-parallel-thread/67084)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 1\
**Last updated:** [August 27, 2021, 9:41am UTC](https://discourse.julialang.org/t/loading-packages-in-a-parallel-thread/67084 "2021-08-27T09:41:20Z")

</div>

Sometimes there are packages that are not needed in the first steps of a script, so performance can be improved by running those first steps and loading the “secondary” packages in parallel. For instance: t = Threads.@s…

---

## [Toggling visibility of widget is effective only after starting the Gtk loop](https://discourse.julialang.org/t/toggling-visibility-of-widget-is-effective-only-after-starting-the-gtk-loop/67086)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 0\
**Last updated:** [August 27, 2021, 8:45am UTC](https://discourse.julialang.org/t/toggling-visibility-of-widget-is-effective-only-after-starting-the-gtk-loop/67086 "2021-08-27T08:45:33Z")

</div>

I would like to start a Gtk.jl window with two buttons, one of them being invisible; the visible button toggles the visibility of the invisible one. I cannot set the visibility of the “invisible” button until after I st…

---

## [How to get the values of a column according to multiple conditions of another column?](https://discourse.julialang.org/t/how-to-get-the-values-of-a-column-according-to-multiple-conditions-of-another-column/67052)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 5\
**Last updated:** [August 27, 2021, 8:18am UTC](https://discourse.julialang.org/t/how-to-get-the-values-of-a-column-according-to-multiple-conditions-of-another-column/67052 "2021-08-27T08:18:14Z")

</div>

I would like to get values from a column according to multiple conditions of another column. Here is an example of what i would like to do: list\_of\_values = df\[df\[:column1\] .== (value1 OR value2),:\].column2 I know tha…

---

## [Saving the value of parameterized functions in DifferentialEquations.jl](https://discourse.julialang.org/t/saving-the-value-of-parameterized-functions-in-differentialequations-jl/67071)

<div class="topic-metadata">

**Author:** [@mys\_721tx](https://discourse.julialang.org/u/mys_721tx)\
**Replies:** 3\
**Last updated:** [August 27, 2021, 6:35am UTC](https://discourse.julialang.org/t/saving-the-value-of-parameterized-functions-in-differentialequations-jl/67071 "2021-08-27T06:35:41Z")

</div>

Hello all, I have the following ODE system in which p is a parameterized function: function fcd!(du, u, p, t) du\[1\] = p(t) - u\[1\] du\[2\] = p(t) / u\[1\] - u\[2\] end I wish to solve the ODE using DifferentialEquati…

---

## [Deploying a web app built with Stipple?](https://discourse.julialang.org/t/deploying-a-web-app-built-with-stipple/65860)

<div class="topic-metadata">

**Author:** [@astrowanders](https://discourse.julialang.org/u/astrowanders)\
**Replies:** 6\
**Last updated:** [August 27, 2021, 6:23am UTC](https://discourse.julialang.org/t/deploying-a-web-app-built-with-stipple/65860 "2021-08-27T06:23:34Z")

</div>

Hello! I built a web app using Stipple, and I’m hoping to get deployment advice. Web App Background: I’m making a web app where owners of pet rabbits can input their rabbit’s details (e.g., weight, age, breed) and foo…

---

## [Show empty bins with 2d Gadfly histogram?](https://discourse.julialang.org/t/show-empty-bins-with-2d-gadfly-histogram/67056)

<div class="topic-metadata">

**Author:** [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Replies:** 1\
**Last updated:** [August 27, 2021, 1:50am UTC](https://discourse.julialang.org/t/show-empty-bins-with-2d-gadfly-histogram/67056 "2021-08-27T01:50:29Z")

</div>

Can’t find it anywhere in the docs, so I guess this isn’t possible with hex or square bins?

---

## [How to define custom AD rule in ForwardDiff](https://discourse.julialang.org/t/how-to-define-custom-ad-rule-in-forwarddiff/67036)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 8\
**Last updated:** [August 27, 2021, 1:45am UTC](https://discourse.julialang.org/t/how-to-define-custom-ad-rule-in-forwarddiff/67036 "2021-08-27T01:45:45Z")

</div>

How to define a custom AD rule in ForwardDiff using DiffRules. I have tried this: using DiffRules using ForwardDiff f(xx) = NaN DiffRules.@define\_diffrule Main.f(xx) = :($xx\[1\] + $xx\[2\], $xx\[1\] - $xx\[2\]) julia\> Forwa…

---

## [Speed up Julia code for simple Monte Carlo Pi estimation (compared to Numba)](https://discourse.julialang.org/t/speed-up-julia-code-for-simple-monte-carlo-pi-estimation-compared-to-numba/59808)

<div class="topic-metadata">

**Author:** [@smpurkis](https://discourse.julialang.org/u/smpurkis)\
**Replies:** 20\
**Last updated:** [August 22, 2021, 4:45am UTC](https://discourse.julialang.org/t/speed-up-julia-code-for-simple-monte-carlo-pi-estimation-compared-to-numba/59808 "2021-08-22T04:45:45Z")

</div>

Hello, I’m benchmarking Julia against some other langauges, mainly against Cython, Numba etc (in this case mainly Numba). I’m running a simple Monte Carlo estimate of Pi. Trying to recreate Python+Numba vs. Julia, and ex…

---

## [Get information on state of IOStream](https://discourse.julialang.org/t/get-information-on-state-of-iostream/66910)

<div class="topic-metadata">

**Author:** [@DorianT](https://discourse.julialang.org/u/DorianT)\
**Replies:** 2\
**Last updated:** [August 26, 2021, 6:46pm UTC](https://discourse.julialang.org/t/get-information-on-state-of-iostream/66910 "2021-08-26T18:46:48Z")

</div>

Hey everyone! I have a function makebatch!(::IOStream, kwargs...) that creates one batch of data to feed to a model (from a file). For this the function takes an IOStream and reads as many lines as it needs to fill the …

---

## [How to sum outputs from DifferentialEquations.jl](https://discourse.julialang.org/t/how-to-sum-outputs-from-differentialequations-jl/67034)

<div class="topic-metadata">

**Author:** [@mgp](https://discourse.julialang.org/u/mgp)\
**Replies:** 7\
**Last updated:** [August 26, 2021, 5:31pm UTC](https://discourse.julialang.org/t/how-to-sum-outputs-from-differentialequations-jl/67034 "2021-08-26T17:31:00Z")

</div>

I am making a series of compartmental ODE infection models using DifferentialEquations. I would like to be able to plot the sum of two or more compartments (e.g. I might have people with undiagnosed infection and diagnos…

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

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