# General Usage

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

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

**Page:** 669

---

## [Conditional test \`? :\` behave differently if switch the turn of return value](https://discourse.julialang.org/t/conditional-test-behave-differently-if-switch-the-turn-of-return-value/51578)

<div class="topic-metadata">

**Author:** [@KyleJT](https://discourse.julialang.org/u/KyleJT)\
**Replies:** 4\
**Last updated:** [December 10, 2020, 12:43pm UTC](https://discourse.julialang.org/t/conditional-test-behave-differently-if-switch-the-turn-of-return-value/51578 "2020-12-10T12:43:58Z")

</div>

Currently, I worked on this homework, i.e. Triangle. Some code snippet for test the isosceles is as following: reset\_pos(idx) = idx == 0 ? 1 : idx function is\_triangle(sides) i = 1 while i \<= length(sides) …

---

## [CxxWrap: building a module for Windows with Cygwin and MingW?](https://discourse.julialang.org/t/cxxwrap-building-a-module-for-windows-with-cygwin-and-mingw/51539)

<div class="topic-metadata">

**Author:** [@jpeeter](https://discourse.julialang.org/u/jpeeter)\
**Replies:** 1\
**Last updated:** [December 10, 2020, 11:59am UTC](https://discourse.julialang.org/t/cxxwrap-building-a-module-for-windows-with-cygwin-and-mingw/51539 "2020-12-10T11:59:18Z")

</div>

I am building a library for Kerberos integration, using CxxWrap to expose some functionality to Julia. This works fine on Linux, but on Windows I’m struggling to get the right toolchain. IIUC - in order to avoid having t…

---

## [Macro hygene escape puzzle](https://discourse.julialang.org/t/macro-hygene-escape-puzzle/51588)

<div class="topic-metadata">

**Author:** [@thisrod](https://discourse.julialang.org/u/thisrod)\
**Replies:** 2\
**Last updated:** [December 10, 2020, 9:05am UTC](https://discourse.julialang.org/t/macro-hygene-escape-puzzle/51588 "2020-12-10T09:05:31Z")

</div>

I want to define a macro similar to those in the code below, where the function f is evaluated in the scope where the macro is expanded, but default is evaluated in module A. \_ \_ \_ \_(\_)\_ | D…

---

## [How to make dataframe from output of loop](https://discourse.julialang.org/t/how-to-make-dataframe-from-output-of-loop/51587)

<div class="topic-metadata">

**Author:** [@sai\_matcha](https://discourse.julialang.org/u/sai_matcha)\
**Replies:** 1\
**Last updated:** [December 10, 2020, 5:54am UTC](https://discourse.julialang.org/t/how-to-make-dataframe-from-output-of-loop/51587 "2020-12-10T05:54:10Z")

</div>

data i have a = (0:1:160) conc = (for i in a println(1.05\*exp(-0.0228\*i)) end i want to get dataframe with “a” and “conc” columns

---

## [When to use a discrete callback in DifferentialEquations.jl](https://discourse.julialang.org/t/when-to-use-a-discrete-callback-in-differentialequations-jl/51493)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 2\
**Last updated:** [December 10, 2020, 4:52am UTC](https://discourse.julialang.org/t/when-to-use-a-discrete-callback-in-differentialequations-jl/51493 "2020-12-10T04:52:38Z")

</div>

I have a fairly large model I am trying to solve (~100 differential equations). There is a particular parameter that changes every 28 days. Right now, I switch this parameter using a callback function function model!(du…

---

## [Aliases not recognized in Julia shell mode](https://discourse.julialang.org/t/aliases-not-recognized-in-julia-shell-mode/51571)

<div class="topic-metadata">

**Author:** [@Xijiang\_Yu](https://discourse.julialang.org/u/Xijiang_Yu)\
**Replies:** 2\
**Last updated:** [December 10, 2020, 1:01am UTC](https://discourse.julialang.org/t/aliases-not-recognized-in-julia-shell-mode/51571 "2020-12-10T01:01:37Z")

</div>

Type ; to enter shell mode. It is easy to run commands like ls. But an alias defined e.g., in .bashrc, like ll is not recognized. The latter gives an error Could not determine command. Any suggestion?

---

## [Find\_zero with Brent method](https://discourse.julialang.org/t/find-zero-with-brent-method/51569)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 3\
**Last updated:** [December 9, 2020, 11:33pm UTC](https://discourse.julialang.org/t/find-zero-with-brent-method/51569 "2020-12-09T23:33:43Z")

</div>

I am trying to find the root of a function f. After using Roots, find\_zero(f, (0, 1), Roots.Brent()) works, but find\_zero(f, (0, 1), Brent()) does not work (error message says Brent not defined). When I use the Bisectio…

---

## [Root isolation of real-rooted integer polynomials](https://discourse.julialang.org/t/root-isolation-of-real-rooted-integer-polynomials/51421)

<div class="topic-metadata">

**Author:** [@malacroi](https://discourse.julialang.org/u/malacroi)\
**Replies:** 12\
**Last updated:** [December 9, 2020, 6:37pm UTC](https://discourse.julialang.org/t/root-isolation-of-real-rooted-integer-polynomials/51421 "2020-12-09T18:37:33Z")

</div>

I have a collection of polynomials with non-negative integer coefficients that I know to be real-rooted with no repeated roots by examining Sturm chains for each. I would like to show that they form an interlacing famil…

---

## [Solving Ax=B for large matrix dimensions efficiently in Julia](https://discourse.julialang.org/t/solving-ax-b-for-large-matrix-dimensions-efficiently-in-julia/51504)

<div class="topic-metadata">

**Author:** [@musman](https://discourse.julialang.org/u/musman)\
**Replies:** 12\
**Last updated:** [December 9, 2020, 2:36pm UTC](https://discourse.julialang.org/t/solving-ax-b-for-large-matrix-dimensions-efficiently-in-julia/51504 "2020-12-09T14:36:27Z")

</div>

Hi all, I have the linear set of equation Ax=b where A can be as large as 20000 x 20000 and is invertible. What is the best computationally efficient way of solving this problem in Julia? I have looked into linear alge…

---

## [Using DifferentialEquations with treatment of uncertainties](https://discourse.julialang.org/t/using-differentialequations-with-treatment-of-uncertainties/51501)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 3\
**Last updated:** [December 9, 2020, 2:30pm UTC](https://discourse.julialang.org/t/using-differentialequations-with-treatment-of-uncertainties/51501 "2020-12-09T14:30:34Z")

</div>

I try to reproduce the code found on the site: The accelerating adoption of Julia The first part of the code is reproduced without problem. Loading the Plots package, not mentioned in the article. But in the part of t…

---

## [Unnesting columns of a data frame containing arrays](https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526)

<div class="topic-metadata">

**Author:** [@jolars](https://discourse.julialang.org/u/jolars)\
**Replies:** 1\
**Last updated:** [December 9, 2020, 2:10pm UTC](https://discourse.julialang.org/t/unnesting-columns-of-a-data-frame-containing-arrays/51526 "2020-12-09T14:10:51Z")

</div>

Let’s say I have the following Julia data frame: using DataFrames d = DataFrame(a = Int64\[\], b = Array{Int64, 1}\[\]) push!(d, (1, \[2, 3\])) 1×2 DataFrame Row │ a b │ Int64 Array… ─────┼───────────────…

---

## [JSON3: ERROR: MethodError: no method matching Array{Int64,2}(::Array{Int64,1})](https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457)

<div class="topic-metadata">

**Author:** [@sz1992](https://discourse.julialang.org/u/sz1992)\
**Replies:** 8\
**Last updated:** [December 9, 2020, 12:41pm UTC](https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457 "2020-12-09T12:41:48Z")

</div>

Hi, i need some help with JSON3. If I add Arrays into my custom structure, I get error on JSON3.read. MWE: Base.@kwdef mutable struct MyStruct3 name::String = "" par1::Int = 10 par2::Int32 = 32 par3::A…

---

## [How do I implement array indexing?](https://discourse.julialang.org/t/how-do-i-implement-array-indexing/51506)

<div class="topic-metadata">

**Author:** [@minetest2048](https://discourse.julialang.org/u/minetest2048)\
**Replies:** 4\
**Last updated:** [December 9, 2020, 10:13am UTC](https://discourse.julialang.org/t/how-do-i-implement-array-indexing/51506 "2020-12-09T10:13:18Z")

</div>

I have this array type: struct Delay{T} head\_idx::Int arr::Vector{T} function Delay{T}(length::Int) where T if ispow2(length) arr = zeros(T,length) new(0, arr) else throw(ArgumentError("Length is not pow…

---

## [Pipe operator with multiple instances](https://discourse.julialang.org/t/pipe-operator-with-multiple-instances/51505)

<div class="topic-metadata">

**Author:** [@kadir-gunel](https://discourse.julialang.org/u/kadir-gunel)\
**Replies:** 1\
**Last updated:** [December 9, 2020, 9:00am UTC](https://discourse.julialang.org/t/pipe-operator-with-multiple-instances/51505 "2020-12-09T09:00:25Z")

</div>

I have a function which takes a Matrix as an argument. And I have a multidimensional array as input (513, 321, 1, 2). The last column represents the number of samples. All I want is to use the |\> pipe operator for each s…

---

## [Understanding Julia documentation syntax](https://discourse.julialang.org/t/understanding-julia-documentation-syntax/51484)

<div class="topic-metadata">

**Author:** [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Replies:** 2\
**Last updated:** [December 9, 2020, 7:46am UTC](https://discourse.julialang.org/t/understanding-julia-documentation-syntax/51484 "2020-12-09T07:46:32Z")

</div>

I’ve decided to familiarize myself with the documentaion system in Julia. For that, I am looking through the source Julia code as the source of inspiration. However, I have encountered a puzzling syntax in one of the s…

---

## [How to Compose a Array Comprehension embedding a Condition Test?](https://discourse.julialang.org/t/how-to-compose-a-array-comprehension-embedding-a-condition-test/51497)

<div class="topic-metadata">

**Author:** [@KyleJT](https://discourse.julialang.org/u/KyleJT)\
**Replies:** 4\
**Last updated:** [December 9, 2020, 7:32am UTC](https://discourse.julialang.org/t/how-to-compose-a-array-comprehension-embedding-a-condition-test/51497 "2020-12-09T07:32:49Z")

</div>

I have a code as the following: list = \[\] for itr in "Watch out! Hello, world" if isletter(itr) append!(list,itr) end end println(list) How can I convert the above code snippet into an array comprehensi…

---

## [Array indexing with begin](https://discourse.julialang.org/t/array-indexing-with-begin/51495)

<div class="topic-metadata">

**Author:** [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Replies:** 2\
**Last updated:** [December 9, 2020, 4:52am UTC](https://discourse.julialang.org/t/array-indexing-with-begin/51495 "2020-12-09T04:52:18Z")

</div>

I ran into the following (Julia v1.5.3): julia\> A = rand(2,2); julia\> Meta.@lower A\[end,1\] :($(Expr(:thunk, CodeInfo( @ none within \`top-level scope' 1 ─ %1 = Base.lastindex(A, 1) │ %2 = Base.getindex(A, %1, 1) └…

---

## [Creating some neural networks](https://discourse.julialang.org/t/creating-some-neural-networks/50958)

<div class="topic-metadata">

**Author:** [@Tomas\_Berky](https://discourse.julialang.org/u/Tomas_Berky)\
**Replies:** 11\
**Last updated:** [December 8, 2020, 8:36pm UTC](https://discourse.julialang.org/t/creating-some-neural-networks/50958 "2020-12-08T20:36:50Z")

</div>

Hello guys, i am getting really desperate. For my bachelor thesis i need to create simple MLP classifying anything, simple MLP for MNIST, simple CNN for MNIST and simple LSTM/GRU network. I am really close to deadline a…

---

## [Problem Adding a dimesion to array/vector](https://discourse.julialang.org/t/problem-adding-a-dimesion-to-array-vector/51431)

<div class="topic-metadata">

**Author:** [@lorrp1](https://discourse.julialang.org/u/lorrp1)\
**Replies:** 7\
**Last updated:** [December 8, 2020, 8:01pm UTC](https://discourse.julialang.org/t/problem-adding-a-dimesion-to-array-vector/51431 "2020-12-08T20:01:15Z")

</div>

Hello, i have a Vector{Any} with 25701 elements made of: 100×40 Array{Float64,2} id like to add a dimension to it so from 25701 \* 100 \* 40\*1 i have tried like written here https://stackoverflow.com/questions/4231231…

---

## [Artifacts, package updating, and system libraries (Julia 1.5.2)](https://discourse.julialang.org/t/artifacts-package-updating-and-system-libraries-julia-1-5-2/51468)

<div class="topic-metadata">

**Author:** [@ko56](https://discourse.julialang.org/u/ko56)\
**Replies:** 5\
**Last updated:** [December 8, 2020, 6:32pm UTC](https://discourse.julialang.org/t/artifacts-package-updating-and-system-libraries-julia-1-5-2/51468 "2020-12-08T18:32:54Z")

</div>

When I do \] up, I see a lot of artifacts corresponding to downloads of libraries that already exist on my FreeBSD 12 system. Thus it seems that the package system is becoming more and more heavy-weight. Being a user, I …

---

## [How to flush stdout](https://discourse.julialang.org/t/how-to-flush-stdout/10146)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 3\
**Last updated:** [December 8, 2020, 5:29pm UTC](https://discourse.julialang.org/t/how-to-flush-stdout/10146 "2020-12-08T17:29:48Z")

</div>

I have a Julia script that has a bunch of println statements interleaved some heavy computation functions. I typically run such scripts, redirect to a file, and then do tail -f to see what’s going on. It appears that t…

---

## [Recursive function does not return last value](https://discourse.julialang.org/t/recursive-function-does-not-return-last-value/51469)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 4\
**Last updated:** [December 8, 2020, 4:17pm UTC](https://discourse.julialang.org/t/recursive-function-does-not-return-last-value/51469 "2020-12-08T16:17:17Z")

</div>

Hi, I wrote a custom algorithm to find the root of my equation (I know, there is much better out there, but my function is not differentiable and it s defined decreasing) Anyway, this is the algorithm. I would like to …

---

## [Bezier curve from python to julia](https://discourse.julialang.org/t/bezier-curve-from-python-to-julia/22630)

<div class="topic-metadata">

**Author:** [@Angela\_Mulenga](https://discourse.julialang.org/u/Angela_Mulenga)\
**Replies:** 2\
**Last updated:** [April 2, 2019, 1:01pm UTC](https://discourse.julialang.org/t/bezier-curve-from-python-to-julia/22630 "2019-04-02T13:01:42Z")

</div>

I have this bezier curve diagram I created in Python but i need to redo it in Julia. I looked up alot of articles but still couldn’t learn how to do it. Please help by commenting on how to do it. It can be a part of thi…

---

## [abspath("PackageName") in a subfolder expands to the wrong path](https://discourse.julialang.org/t/abspath-packagename-in-a-subfolder-expands-to-the-wrong-path/51447)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [December 8, 2020, 10:21am UTC](https://discourse.julialang.org/t/abspath-packagename-in-a-subfolder-expands-to-the-wrong-path/51447 "2020-12-08T10:21:35Z")

</div>

I have a package, BetaML, where I included in a subfolder “notebooks” some notebooks for documentation. If in these notebooks I run abspath("BetaML"), it expands to “/home/lobianco/.julia/dev/BetaML/notebooks/BetaML” (t…

---

## [Makie.jl - How to plot a colorlegend?](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-colorlegend/46132)

<div class="topic-metadata">

**Author:** [@yosuga](https://discourse.julialang.org/u/yosuga)\
**Replies:** 1\
**Last updated:** [December 8, 2020, 9:37am UTC](https://discourse.julialang.org/t/makie-jl-how-to-plot-a-colorlegend/46132 "2020-12-08T09:37:47Z")

</div>

I’m trying to plot a colorlegend when its colorrang is (::Float64,::Float64). But this sample code doesn’t work. using Makie using FileIO using LinearAlgebra using AbstractPlotting r = LinRange(-20, 20, 500); # our v…

---

## [How to use \`Anonymous Function\` in \`Function Piping\`?](https://discourse.julialang.org/t/how-to-use-anonymous-function-in-function-piping/51392)

<div class="topic-metadata">

**Author:** [@KyleJT](https://discourse.julialang.org/u/KyleJT)\
**Replies:** 8\
**Last updated:** [December 8, 2020, 7:47am UTC](https://discourse.julialang.org/t/how-to-use-anonymous-function-in-function-piping/51392 "2020-12-08T07:47:24Z")

</div>

Currently, I’m learning the Function Piping. And I try to imitate the following example: julia\> 1:10 |\> sum |\> sqrt with function piping to realize my purpose: Step 1: Square each element in the list, Step 2: Sum the…

---

## [URLs Required for Julia 1.5 Package Manager](https://discourse.julialang.org/t/urls-required-for-julia-1-5-package-manager/51420)

<div class="topic-metadata">

**Author:** [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Replies:** 2\
**Last updated:** [December 8, 2020, 12:01am UTC](https://discourse.julialang.org/t/urls-required-for-julia-1-5-package-manager/51420 "2020-12-08T00:01:49Z")

</div>

Regarding the configuration of firewalls, what new URLs are required to reach the package management infrastructure that is used by Julia v1.5?

---

## [Round values for dataset](https://discourse.julialang.org/t/round-values-for-dataset/51159)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 13\
**Last updated:** [December 7, 2020, 8:13pm UTC](https://discourse.julialang.org/t/round-values-for-dataset/51159 "2020-12-07T20:13:00Z")

</div>

x=1.000001 df=DataFrame(A=x) for i in 1:10 x=x+1 push!(df,(x)) end Is there a way to round this to say, 5 decimal places?, and to have that rounding thougout the dataframe?

---

## [Simple conditional loop](https://discourse.julialang.org/t/simple-conditional-loop/51402)

<div class="topic-metadata">

**Author:** [@darleybarreto](https://discourse.julialang.org/u/darleybarreto)\
**Replies:** 4\
**Last updated:** [December 7, 2020, 4:05pm UTC](https://discourse.julialang.org/t/simple-conditional-loop/51402 "2020-12-07T16:05:37Z")

</div>

Hi folks, I have a question about ifs inside for loops. Suppose I have this function: function c\_cheating(high) total = 0 high \*= 2 for i in 4:4:high total += i end total end Giving @btime c\_cheating(1\_000\_000)…

---

## [Edit PNG PLTE](https://discourse.julialang.org/t/edit-png-plte/51305)

<div class="topic-metadata">

**Author:** [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Replies:** 6\
**Last updated:** [December 7, 2020, 2:05pm UTC](https://discourse.julialang.org/t/edit-png-plte/51305 "2020-12-07T14:05:05Z")

</div>

The PNG format specifies an optional color palette (PLTE chunk). I want to edit this palette with Julia but do not find a starting point. Is there an existing library which provides this kind of “low level” control over …

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

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