# General Usage

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

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

**Page:** 446

---

## [How to translate bash to .bat](https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 25\
**Last updated:** [May 26, 2022, 1:43am UTC](https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652 "2022-05-26T01:43:41Z")

</div>

I have a bash script to create a Julia system image. (KiteSimulators.jl/create\_sys\_image at main · aenarete/KiteSimulators.jl · GitHub) Now I want to convert it to a .bat file for windows users. How could I translate th…

---

## [Arithmetic broadcasting in Julia 5x slower than MATLAB](https://discourse.julialang.org/t/arithmetic-broadcasting-in-julia-5x-slower-than-matlab/81628)

<div class="topic-metadata">

**Author:** [@elenev](https://discourse.julialang.org/u/elenev)\
**Replies:** 17\
**Last updated:** [May 26, 2022, 12:46am UTC](https://discourse.julialang.org/t/arithmetic-broadcasting-in-julia-5x-slower-than-matlab/81628 "2022-05-26T00:46:42Z")

</div>

I was surprised to find a fairly simple broadcasting operation on somewhat large arrays be considerably slower in Julia relative to MATLAB. Is there some unattainable level of optimization that folks at MathWorks have fi…

---

## [Is there a function to permute columns or rows of a matrix in place?](https://discourse.julialang.org/t/is-there-a-function-to-permute-columns-or-rows-of-a-matrix-in-place/81667)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [May 25, 2022, 8:09pm UTC](https://discourse.julialang.org/t/is-there-a-function-to-permute-columns-or-rows-of-a-matrix-in-place/81667 "2022-05-25T20:09:35Z")

</div>

Slicing works to create a permuted copy. But, is there some way to get the permutation in-place?

---

## [Change variable outside of local scope](https://discourse.julialang.org/t/change-variable-outside-of-local-scope/81645)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 4\
**Last updated:** [May 25, 2022, 3:15pm UTC](https://discourse.julialang.org/t/change-variable-outside-of-local-scope/81645 "2022-05-25T15:15:07Z")

</div>

Hi everyone, I try to solve a model and would like to update the parameters of the model with each iteration. For instance, I have a function like this: function solve\_GE(par::Pars) res = zeros(2) f!(x) = resi…

---

## [?swap: Swap values of two arrays. As fast as you can, dear](https://discourse.julialang.org/t/swap-swap-values-of-two-arrays-as-fast-as-you-can-dear/81661)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 1\
**Last updated:** [May 25, 2022, 2:53pm UTC](https://discourse.julialang.org/t/swap-swap-values-of-two-arrays-as-fast-as-you-can-dear/81661 "2022-05-25T14:53:00Z")

</div>

LAPACK has a function called ?swap to swap the values stored in two arrays subroutine dswap (n,dx,incx,dy,incy) # # interchanges two vectors. # uses unrolled loops for increments equal one. # jack don…

---

## [Help with sciml\_train](https://discourse.julialang.org/t/help-with-sciml-train/81657)

<div class="topic-metadata">

**Author:** [@Marius\_123](https://discourse.julialang.org/u/Marius_123)\
**Replies:** 0\
**Last updated:** [May 25, 2022, 2:03pm UTC](https://discourse.julialang.org/t/help-with-sciml-train/81657 "2022-05-25T14:03:17Z")

</div>

Hello, i am trying to fit parameters of an ODE system to data. In this case, not all of the componenets have the same time points where measurements are taken. If i set up the loss function and plug it into sciml\_train, …

---

## [AlgebraOfGraphics: How to add text to a plot?](https://discourse.julialang.org/t/algebraofgraphics-how-to-add-text-to-a-plot/81646)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 1\
**Last updated:** [May 25, 2022, 1:31pm UTC](https://discourse.julialang.org/t/algebraofgraphics-how-to-add-text-to-a-plot/81646 "2022-05-25T13:31:16Z")

</div>

How can I add text at some position in AlgebraOfGraphics?

---

## [What are the benefits of using IOBuffer()?](https://discourse.julialang.org/t/what-are-the-benefits-of-using-iobuffer/28693)

<div class="topic-metadata">

**Author:** [@chbian](https://discourse.julialang.org/u/chbian)\
**Replies:** 20\
**Last updated:** [May 25, 2022, 1:21pm UTC](https://discourse.julialang.org/t/what-are-the-benefits-of-using-iobuffer/28693 "2022-05-25T13:21:13Z")

</div>

Are there potential benefits of writing to an IOBuffer() rather than printing to a file IO directly? For example, I see the following implementation, function append(io::IO, data::SomeCompositeType) # append a mutable s…

---

## [Type instability with tuples of functions and parameters](https://discourse.julialang.org/t/type-instability-with-tuples-of-functions-and-parameters/81588)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 13\
**Last updated:** [May 25, 2022, 6:30am UTC](https://discourse.julialang.org/t/type-instability-with-tuples-of-functions-and-parameters/81588 "2022-05-25T06:30:19Z")

</div>

My general application of interest requires a vector of functions of the form f(x, y, p), for some known parameters p. I put the functions in a Tuple so that their types are known, and define for example the following st…

---

## [Yet another TCO thread](https://discourse.julialang.org/t/yet-another-tco-thread/81146)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 5\
**Last updated:** [May 25, 2022, 6:06am UTC](https://discourse.julialang.org/t/yet-another-tco-thread/81146 "2022-05-25T06:06:53Z")

</div>

Also, AFAIK, Julia doesn’t implement the tail-call optimization yet, which is crucial for the performance of recursive functions.

---

## [I have: Vector{UInt8}. I need: BitVector](https://discourse.julialang.org/t/i-have-vector-uint8-i-need-bitvector/2286)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 6\
**Last updated:** [May 25, 2022, 4:59am UTC](https://discourse.julialang.org/t/i-have-vector-uint8-i-need-bitvector/2286 "2022-05-25T04:59:28Z")

</div>

I have julia\> z 3-element Array{UInt8,1}: 0x66 0x6f 0x6f What I’d like is the (24-element) BitVector representation of this sequence. However, my attempt to use reinterpret yielded a very confusing error: julia\> re…

---

## [Question about defining parameters in Julia?](https://discourse.julialang.org/t/question-about-defining-parameters-in-julia/81617)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 1\
**Last updated:** [May 24, 2022, 10:05pm UTC](https://discourse.julialang.org/t/question-about-defining-parameters-in-julia/81617 "2022-05-24T22:05:44Z")

</div>

Dear all, Is this a good way to define parameters in Julia? using Parameters para\_def = @with\_kw ( β=0.87, δ=0.06, γ=2, α=0.35, wage=1, za=1, ϵ=3, μ=ϵ / (ϵ - 1), D=1, phil=0.00,…

---

## [Supporting offset arrays without explicit dependency](https://discourse.julialang.org/t/supporting-offset-arrays-without-explicit-dependency/81565)

<div class="topic-metadata">

**Author:** [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Replies:** 13\
**Last updated:** [May 24, 2022, 9:46pm UTC](https://discourse.julialang.org/t/supporting-offset-arrays-without-explicit-dependency/81565 "2022-05-24T21:46:11Z")

</div>

In my package (NCDatasets) I am calling a C function which expect an array as input. I use two functions so that ranges, bit arrays, transposed arrays,… get converted to plain arrays. However this does not work for off…

---

## [How to rewrite a function for Julia codes?](https://discourse.julialang.org/t/how-to-rewrite-a-function-for-julia-codes/81616)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 2\
**Last updated:** [May 24, 2022, 9:05pm UTC](https://discourse.julialang.org/t/how-to-rewrite-a-function-for-julia-codes/81616 "2022-05-24T21:05:29Z")

</div>

Dear all, I want to write a function for the codes. while VFIcontinue == 1 error\_vfi\_old = error\_vfi for i\_state in 1:n\_state prob\_mat = repeat(transpose(prob\[i\_state, :\]), n\_choice, 1) EXP\[:, i\_…

---

## [Question about Float64 and Int?](https://discourse.julialang.org/t/question-about-float64-and-int/81605)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 12\
**Last updated:** [May 24, 2022, 8:35pm UTC](https://discourse.julialang.org/t/question-about-float64-and-int/81605 "2022-05-24T20:35:14Z")

</div>

Dear all, I have an Int array and Float64 array. And I want to merge them. julia\> a =\[1, 2, 3\]; julia\> b =\[1.0, 2.0, 3.0\]; julia\> A =hcat(a, b) 3×2 Matrix{Float64}: 1.0 1.0 2.0 2.0 3.0 3.0 Here I get a Float6…

---

## [How to get vector from set of ranges?](https://discourse.julialang.org/t/how-to-get-vector-from-set-of-ranges/81571)

<div class="topic-metadata">

**Author:** [@Minimum-Pollution-96](https://discourse.julialang.org/u/Minimum-Pollution-96)\
**Replies:** 7\
**Last updated:** [May 24, 2022, 6:55pm UTC](https://discourse.julialang.org/t/how-to-get-vector-from-set-of-ranges/81571 "2022-05-24T18:55:45Z")

</div>

I am trying to create a vector using in-line for loop. indices = \[2,5,6,8\] \[i:i+6; for i in indices\] which returns 4-element Vector{UnitRange{Int64}}: 2:8 5:11 6:12 8:14 How to create vector of values instead o…

---

## [Does eachline loads whole stream/file in memory?](https://discourse.julialang.org/t/does-eachline-loads-whole-stream-file-in-memory/81602)

<div class="topic-metadata">

**Author:** [@Maxim\_Lubov](https://discourse.julialang.org/u/Maxim_Lubov)\
**Replies:** 1\
**Last updated:** [May 24, 2022, 5:27pm UTC](https://discourse.julialang.org/t/does-eachline-loads-whole-stream-file-in-memory/81602 "2022-05-24T17:27:12Z")

</div>

My problem is following. I have a huge .csv file stored in S3 bucket. I don’t want to load it on disk, just read it line by line with the consecutive processing of each line. For the locally stored files I usually use CS…

---

## [\`eachindex(x)\` replacement for \`1:length(x)-1\` and similar](https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 27\
**Last updated:** [May 24, 2022, 4:54pm UTC](https://discourse.julialang.org/t/eachindex-x-replacement-for-1-length-x-1-and-similar/81481 "2022-05-24T16:54:45Z")

</div>

I have been following the discussion lately about how functions that take an AbstractArray argument should avoid using the pattern 1:length(x) as an iterator because it is incompatible with interfaces like OffsetArrays.j…

---

## [Looping constructs, construct equations, ModelingToolkit](https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568)

<div class="topic-metadata">

**Author:** [@Rohan\_Rajagopal](https://discourse.julialang.org/u/Rohan_Rajagopal)\
**Replies:** 1\
**Last updated:** [May 24, 2022, 1:13pm UTC](https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568 "2022-05-24T13:13:46Z")

</div>

Is it possible to define equations using looping constructs, or is there a “correct” way to implement the following systems of equations, N=3; @parameters μ ϵ η\_ω η\_a A β\[1:N\] ω\[1:N\] θ\[1:N, 1:N\] @variables z\[1:N^2+3\*N …

---

## [Faust.jl fails to precompile with Julia v1.7.2](https://discourse.julialang.org/t/faust-jl-fails-to-precompile-with-julia-v1-7-2/81573)

<div class="topic-metadata">

**Author:** [@sletz](https://discourse.julialang.org/u/sletz)\
**Replies:** 1\
**Last updated:** [May 24, 2022, 12:58pm UTC](https://discourse.julialang.org/t/faust-jl-fails-to-precompile-with-julia-v1-7-2/81573 "2022-05-24T12:58:56Z")

</div>

Faust.jl fails to compile with Julia v1.7.2 (tested on macOS): using Faust \[ Info: Precompiling Faust \[b0df9959-3f7b-4e37-9fbf-63cb195e8303\] ERROR: LoadError: TypeError: in cfunction method definition, expected Type, go…

---

## [Standalone PackageCompiler app with Plots fails with GR\_jll error](https://discourse.julialang.org/t/standalone-packagecompiler-app-with-plots-fails-with-gr-jll-error/81507)

<div class="topic-metadata">

**Author:** [@ConnectedSystems](https://discourse.julialang.org/u/ConnectedSystems)\
**Replies:** 3\
**Last updated:** [May 24, 2022, 12:03pm UTC](https://discourse.julialang.org/t/standalone-packagecompiler-app-with-plots-fails-with-gr-jll-error/81507 "2022-05-24T12:03:41Z")

</div>

Putting together an app that displays a plot of results at the end. Unfortunately, the plot never displays at the end. Instead, there is an error message about GR\_jll, although I see it listed when it is compiling (see b…

---

## [How to efficiently handle parallelism on a DistributedArray](https://discourse.julialang.org/t/how-to-efficiently-handle-parallelism-on-a-distributedarray/81098)

<div class="topic-metadata">

**Author:** [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Replies:** 8\
**Last updated:** [May 24, 2022, 10:03am UTC](https://discourse.julialang.org/t/how-to-efficiently-handle-parallelism-on-a-distributedarray/81098 "2022-05-24T10:03:38Z")

</div>

I’m working with a DArray from DistributedArrays.jl. I want each process to work on its own part of the array independently, and access the rest of the array only when it needs a nearest neighbor which doesn’t reside in …

---

## [Writing documentation for a project with DrWatson](https://discourse.julialang.org/t/writing-documentation-for-a-project-with-drwatson/81554)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 4\
**Last updated:** [May 24, 2022, 9:36am UTC](https://discourse.julialang.org/t/writing-documentation-for-a-project-with-drwatson/81554 "2022-05-24T09:36:40Z")

</div>

I have a DrWatson project for which I want to write some documentation. I was wondering if I can use Documenter.jl even though this is a project and not a package. Are there any tips for writing documentation for a pro…

---

## [Push! not working as expected](https://discourse.julialang.org/t/push-not-working-as-expected/81563)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [May 24, 2022, 9:32am UTC](https://discourse.julialang.org/t/push-not-working-as-expected/81563 "2022-05-24T09:32:07Z")

</div>

What am I doing wrong here: using KiteUtils s=demo\_state(7) vec=Vector{SysState{7}}\[\] typeof(s) Output SysState{7} Now I try to push s into the vector vec julia\> push!(vec,s) ERROR: MethodError: Cannot \`convert\` an …

---

## [Current Status of ppc64le Support](https://discourse.julialang.org/t/current-status-of-ppc64le-support/47279)

<div class="topic-metadata">

**Author:** [@michaela](https://discourse.julialang.org/u/michaela)\
**Replies:** 9\
**Last updated:** [May 24, 2022, 7:41am UTC](https://discourse.julialang.org/t/current-status-of-ppc64le-support/47279 "2022-05-24T07:41:42Z")

</div>

I was wondering what the status of Julia support for the ppc64le architecture is for the most recent versions of Julia (v1.5.1+). I saw in this GitHub Issue discussion that there were talks of working with IBM to make th…

---

## [How to save output from GraphViz.jl to pdf?](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476)

<div class="topic-metadata">

**Author:** [@Norman](https://discourse.julialang.org/u/Norman)\
**Replies:** 4\
**Last updated:** [May 23, 2022, 10:47pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476 "2022-05-23T22:47:12Z")

</div>

Hi, Could someone show an example of printing the output generated from GraphViz.jl to a pdf file? Let’s say just use the example below. Thank you! dot""" graph graphname { // The label attribute can be used to ch…

---

## [How can I transform this matlab code into Julia](https://discourse.julialang.org/t/how-can-i-transform-this-matlab-code-into-julia/81351)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 28\
**Last updated:** [May 23, 2022, 8:47pm UTC](https://discourse.julialang.org/t/how-can-i-transform-this-matlab-code-into-julia/81351 "2022-05-23T20:47:55Z")

</div>

\>\> val = zeros(3, 3); \>\> row = zeros(3, 3); \>\> A = \[1 2 3; 6 5 1; 1 7 4\]; \[val(1, :), row(1, :)\] = max(A) val = 6 7 4 0 0 0 0 0 0 row = 2 3 3 0 0 0 …

---

## [What is the equivalence to Matlab code "sparse(1:3, \[1 3 5\], \[11 12 13\])" in Julia](https://discourse.julialang.org/t/what-is-the-equivalence-to-matlab-code-sparse-1-3-1-3-5-11-12-13-in-julia/81537)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 2\
**Last updated:** [May 23, 2022, 8:34pm UTC](https://discourse.julialang.org/t/what-is-the-equivalence-to-matlab-code-sparse-1-3-1-3-5-11-12-13-in-julia/81537 "2022-05-23T20:34:51Z")

</div>

What is equivalent to the below Matlab code in Julia. Which creates a sparse matrix of 1:3 rows and fills the elements in columns \[1 3 5\] (corresponding to rows 1:3) by \[11 12 13\] \>\> sparse(1:3, \[1 3 5\], \[11 12 13\]) an…

---

## [Function \`confusion\_matrix \` in MLJ always fails](https://discourse.julialang.org/t/function-confusion-matrix-in-mlj-always-fails/81521)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 4\
**Last updated:** [May 23, 2022, 7:57pm UTC](https://discourse.julialang.org/t/function-confusion-matrix-in-mlj-always-fails/81521 "2022-05-23T19:57:49Z")

</div>

Hello, I try to caculate a confusion matrix in Julia, but I meet some ERROR and it is hard for me to debug, any suggestion? Thanks you. here is my code using MLJ, CategoricalArrays # Status \`~/.julia/environments/v1…

---

## [Passing struct with Union type to other function](https://discourse.julialang.org/t/passing-struct-with-union-type-to-other-function/81482)

<div class="topic-metadata">

**Author:** [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Replies:** 6\
**Last updated:** [May 23, 2022, 8:01pm UTC](https://discourse.julialang.org/t/passing-struct-with-union-type-to-other-function/81482 "2022-05-23T20:01:45Z")

</div>

I’m pretty new to Julia so I might have missed something pretty elementary. I have defined the following struct which contains some parameters with default values. @with\_kw struct Par1 D::Union{Float64, VecOrMat{Fl…

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

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