# General Usage

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

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

**Page:** 353

---

## [How to Fill Area between 3 Functions / Curves?](https://discourse.julialang.org/t/how-to-fill-area-between-3-functions-curves/91954)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 4\
**Last updated:** [December 22, 2022, 10:18am UTC](https://discourse.julialang.org/t/how-to-fill-area-between-3-functions-curves/91954 "2022-12-22T10:18:49Z")

</div>

Hi all, it is more than 2 curves problem now, I want to fill an area / region between 3 curves. Currently I can only manage to fill area between 2 curves: using Plots, LaTeXStrings, Roots, SymPy gr() x = collect(ra…

---

## [How to define a struct programmatically?](https://discourse.julialang.org/t/how-to-define-a-struct-programmatically/58621)

<div class="topic-metadata">

**Author:** [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Replies:** 10\
**Last updated:** [April 5, 2021, 6:12pm UTC](https://discourse.julialang.org/t/how-to-define-a-struct-programmatically/58621 "2021-04-05T18:12:49Z")

</div>

suppose I have parametric struct Mystruct{N} where N depends on the contents of data. Now, I need a “super-struct” that contains variable numbers of of Mystructs, e.g. depends on data I may need: struct Superstruct{N1,…

---

## [ReverseDiff method error in multiplication](https://discourse.julialang.org/t/reversediff-method-error-in-multiplication/91758)

<div class="topic-metadata">

**Author:** [@slwu89](https://discourse.julialang.org/u/slwu89)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 8:49pm UTC](https://discourse.julialang.org/t/reversediff-method-error-in-multiplication/91758 "2022-12-21T20:49:21Z")

</div>

Hi all, I have a question about a method error in ReverseDiff.jl, which arises in my function when calling \* (line p/g + p\*(a-am) in my MWE below), and using ReverseDiff to calculate the Hessian matrix. I’ve checked tha…

---

## [Summarizing Float64 values after grouping by different time scales from DateTime object](https://discourse.julialang.org/t/summarizing-float64-values-after-grouping-by-different-time-scales-from-datetime-object/90320)

<div class="topic-metadata">

**Author:** [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Replies:** 2\
**Last updated:** [December 21, 2022, 3:56pm UTC](https://discourse.julialang.org/t/summarizing-float64-values-after-grouping-by-different-time-scales-from-datetime-object/90320 "2022-12-21T15:56:59Z")

</div>

I have a data frame with two columns. Column time has datetime elements while column values has Float64 elements. I want to group the column time by year, month, day, and hour to calculate the average of the values. I c…

---

## [Speeding up operations on large arrays](https://discourse.julialang.org/t/speeding-up-operations-on-large-arrays/91966)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 6\
**Last updated:** [December 21, 2022, 5:06pm UTC](https://discourse.julialang.org/t/speeding-up-operations-on-large-arrays/91966 "2022-12-21T17:06:06Z")

</div>

Hi, I’m working on a code that needs to calculate many, simple arithmetic on slices of large arrays. Ideally I’d like to understand how to speed up this code and explored multiple approaches: function sub\_single(x1, x…

---

## [Optional elements in vector literal](https://discourse.julialang.org/t/optional-elements-in-vector-literal/91963)

<div class="topic-metadata">

**Author:** [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Replies:** 5\
**Last updated:** [December 21, 2022, 4:33pm UTC](https://discourse.julialang.org/t/optional-elements-in-vector-literal/91963 "2022-12-21T16:33:27Z")

</div>

is there a nice way to optionally include an element in a vector literal construction? something like foo = \[1, 2, @maybe x 3, 4, 5\] where only if x==true is 3 included.

---

## [Loss of smoothness of a MeshViz/Makie plot when assigning colors to vertices](https://discourse.julialang.org/t/loss-of-smoothness-of-a-meshviz-makie-plot-when-assigning-colors-to-vertices/91964)

<div class="topic-metadata">

**Author:** [@\_stla](https://discourse.julialang.org/u/_stla)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 4:32pm UTC](https://discourse.julialang.org/t/loss-of-smoothness-of-a-meshviz-makie-plot-when-assigning-colors-to-vertices/91964 "2022-12-21T16:32:31Z")

</div>

Hello, I have a 3D mesh made with the Meshes package. When I plot it with MeshViz using the default attributes, it is smooth. But when I assign some colors to the vertices of the mesh, it is not smooth anymore: How …

---

## [Stepping thru a matrix](https://discourse.julialang.org/t/stepping-thru-a-matrix/91956)

<div class="topic-metadata">

**Author:** [@jdarnold](https://discourse.julialang.org/u/jdarnold)\
**Replies:** 2\
**Last updated:** [December 21, 2022, 3:03pm UTC](https://discourse.julialang.org/t/stepping-thru-a-matrix/91956 "2022-12-21T15:03:30Z")

</div>

I’m just wondering if there is a easier / better way to step thru the elements of a 10x2 matrix, where I want to get each part of the x2 as an element: testmatrix = zeros(Int,10,2) for tidx = 1:size(testmatrix)\[1\] …

---

## [VCS Julia Formatter error](https://discourse.julialang.org/t/vcs-julia-formatter-error/91943)

<div class="topic-metadata">

**Author:** [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 2:31pm UTC](https://discourse.julialang.org/t/vcs-julia-formatter-error/91943 "2022-12-21T14:31:20Z")

</div>

Hi! 6 weeks ago everything was working fine. I came back to one of my projects. Before doing anything, I had 3 uncommitted changes: a change in todo.txt file, new pdf file, change in jupyter file. I committed the change…

---

## [How to Create a Brackets for certain length in Plots?](https://discourse.julialang.org/t/how-to-create-a-brackets-for-certain-length-in-plots/91930)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 2:18pm UTC](https://discourse.julialang.org/t/how-to-create-a-brackets-for-certain-length-in-plots/91930 "2022-12-21T14:18:36Z")

</div>

Hi all, I want to create a bracket like this: I currently use a line and two bars to replace the bracket, I try to use } with rotation and increase the length and it is not working. this is my code: using Plots, La…

---

## [How to get the Cartesian indices of a row/column in a \`Matrix\`?](https://discourse.julialang.org/t/how-to-get-the-cartesian-indices-of-a-row-column-in-a-matrix/91940)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 3\
**Last updated:** [December 21, 2022, 2:22pm UTC](https://discourse.julialang.org/t/how-to-get-the-cartesian-indices-of-a-row-column-in-a-matrix/91940 "2022-12-21T14:22:24Z")

</div>

Given a Matrix m, setting its values is simple: m = rand(4, 4) m\[begin, :\] = 1 m\[:, end\] = 2 But how can we get the indices of its first row/last column of elements? I guess it is similar to this question: Eachindex fo…

---

## [Color ramp](https://discourse.julialang.org/t/color-ramp/91946)

<div class="topic-metadata">

**Author:** [@\_stla](https://discourse.julialang.org/u/_stla)\
**Replies:** 7\
**Last updated:** [December 21, 2022, 1:37pm UTC](https://discourse.julialang.org/t/color-ramp/91946 "2022-12-21T13:37:35Z")

</div>

Hello, I’m looking for a package providing color ramps. By color ramp I mean a function defined by a color palette and which maps a number between 0 and 1 to a color of this palette, by interpolation. 0 is mapped to the…

---

## [How to do an atomic compare and swap on a SharedArray](https://discourse.julialang.org/t/how-to-do-an-atomic-compare-and-swap-on-a-sharedarray/91942)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 0\
**Last updated:** [December 21, 2022, 10:52am UTC](https://discourse.julialang.org/t/how-to-do-an-atomic-compare-and-swap-on-a-sharedarray/91942 "2022-12-21T10:52:24Z")

</div>

Hi all :slight\_smile: I want to use shared memory and do an atomic\_cas! (Atomically compare-and-set) in some file/ shared array. How would I do that? Thanks!

---

## [How to use \`invoke\` with a functor](https://discourse.julialang.org/t/how-to-use-invoke-with-a-functor/91949)

<div class="topic-metadata">

**Author:** [@abraunst](https://discourse.julialang.org/u/abraunst)\
**Replies:** 0\
**Last updated:** [December 21, 2022, 12:22pm UTC](https://discourse.julialang.org/t/how-to-use-invoke-with-a-functor/91949 "2022-12-21T12:22:23Z")

</div>

This is maybe a stupid question, but I couldn’t find the answer in the documentation. I need it mainly for debugging, but a minimal example would be abstract type A end (::A)() = "A" struct B \<: A end (::B)() = "B" b = …

---

## [Check that two julia files lead to the same code](https://discourse.julialang.org/t/check-that-two-julia-files-lead-to-the-same-code/91918)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 6\
**Last updated:** [December 21, 2022, 11:05am UTC](https://discourse.julialang.org/t/check-that-two-julia-files-lead-to-the-same-code/91918 "2022-12-21T11:05:46Z")

</div>

Let’s say I have these two files: a.jl function foo() println("hello") end and b.jl """ foo() A function """ function foo() println("hello") end is there an easy way to assess that these two files are “the sa…

---

## [A minimal example with Base.redirect\_stdout](https://discourse.julialang.org/t/a-minimal-example-with-base-redirect-stdout/64245)

<div class="topic-metadata">

**Author:** [@harris-chris](https://discourse.julialang.org/u/harris-chris)\
**Replies:** 10\
**Last updated:** [December 21, 2022, 10:03am UTC](https://discourse.julialang.org/t/a-minimal-example-with-base-redirect-stdout/64245 "2022-12-21T10:03:24Z")

</div>

Hello all I’m having a bit of difficulty making the Base.redirect\_stdout(f::Function, stream) method work. What I would have thought would be a minimal working example is in fact a minimal failing example: out = Pipe()…

---

## [Delete user input from terminal?](https://discourse.julialang.org/t/delete-user-input-from-terminal/91619)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 4\
**Last updated:** [December 20, 2022, 11:50pm UTC](https://discourse.julialang.org/t/delete-user-input-from-terminal/91619 "2022-12-20T23:50:26Z")

</div>

I’m working on a little project that’s a “personal assistant” to me manage my todo list. I’m using Term.jl to make it look pretty. I’m trying to emulate sort of a chat box aesthetic. It’s bugging me that I can’t rem…

---

## [\`sort\` vs \`copy\`+\`sort!\`](https://discourse.julialang.org/t/sort-vs-copy-sort/91919)

<div class="topic-metadata">

**Author:** [@Dan](https://discourse.julialang.org/u/Dan)\
**Replies:** 3\
**Last updated:** [December 20, 2022, 11:47pm UTC](https://discourse.julialang.org/t/sort-vs-copy-sort/91919 "2022-12-20T23:47:19Z")

</div>

This is run on Julia 1.8.3 using BenchmarkTools function benchsort(L) v = rand(L) @show L @btime sort($v) @btime sort!($v) @btime sort!(copy($v)) nothing end Running this with 2048 length vecto…

---

## [Is there a way to enable syntax highlighting for Expr objects in the REPL?](https://discourse.julialang.org/t/is-there-a-way-to-enable-syntax-highlighting-for-expr-objects-in-the-repl/91920)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 0\
**Last updated:** [December 20, 2022, 11:21pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-enable-syntax-highlighting-for-expr-objects-in-the-repl/91920 "2022-12-20T23:21:03Z")

</div>

I think it will be easier to debug expressions returned by macros if they could be syntax highlighted. The package OhMyREPL already enables syntax highlighting in the REPL (which i use), but it doesn’t highlight expressi…

---

## [Precompilation/recompilation - what's going on?](https://discourse.julialang.org/t/precompilation-recompilation-whats-going-on/91829)

<div class="topic-metadata">

**Author:** [@FedeClaudi](https://discourse.julialang.org/u/FedeClaudi)\
**Replies:** 3\
**Last updated:** [December 20, 2022, 10:23pm UTC](https://discourse.julialang.org/t/precompilation-recompilation-whats-going-on/91829 "2022-12-20T22:23:03Z")

</div>

Hey folks, I’m working on improving time to first X in Term.jl by precompilation etc, but it’s not a tool I’m super familiar with these things so I was hoping someone might give me some advice. For reference, I’ve red s…

---

## [Use the Docstrings Luke](https://discourse.julialang.org/t/use-the-docstrings-luke/91915)

<div class="topic-metadata">

**Author:** [@johnh](https://discourse.julialang.org/u/johnh)\
**Replies:** 1\
**Last updated:** [December 20, 2022, 9:55pm UTC](https://discourse.julialang.org/t/use-the-docstrings-luke/91915 "2022-12-20T21:55:39Z")

</div>

I just had a small revelation… following a post on the issasigned function I wanted to discover more about it. Googling for the documentation I saw a reddit article which prompted the reader to read the docstrings… So r…

---

## [Concatenation causes multiplication type problems in ReverseDiff](https://discourse.julialang.org/t/concatenation-causes-multiplication-type-problems-in-reversediff/91917)

<div class="topic-metadata">

**Author:** [@fratrik](https://discourse.julialang.org/u/fratrik)\
**Replies:** 0\
**Last updated:** [December 20, 2022, 9:38pm UTC](https://discourse.julialang.org/t/concatenation-causes-multiplication-type-problems-in-reversediff/91917 "2022-12-20T21:38:19Z")

</div>

using ReverseDiff function f(a) b = \[1 2\] (\[a; b\]\*a)\*a \[a\*a\*a; b\*a\*a\] \[a\*a; b\*a\]\*a # error here 0 end ReverseDiff.hessian(f, randn(2, 2)) the code fails on \[a\*a; b\*a\]\*a with message ERROR: L…

---

## [Looking for good way to save system image while developing Base](https://discourse.julialang.org/t/looking-for-good-way-to-save-system-image-while-developing-base/91912)

<div class="topic-metadata">

**Author:** [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Replies:** 0\
**Last updated:** [December 20, 2022, 7:59pm UTC](https://discourse.julialang.org/t/looking-for-good-way-to-save-system-image-while-developing-base/91912 "2022-12-20T19:59:00Z")

</div>

Does anyone have a good workflow for making archives or backups of a system image built using make while making change to Base? I know that Revise can work for some situations, but I would love to have a good way to rol…

---

## [Why documentation links are often broken?](https://discourse.julialang.org/t/why-documentation-links-are-often-broken/91903)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 3\
**Last updated:** [December 20, 2022, 5:15pm UTC](https://discourse.julialang.org/t/why-documentation-links-are-often-broken/91903 "2022-12-20T17:15:09Z")

</div>

It is quite common to find broken Julia package documentation links, like this one (see docs stable link in the page): Why is this and is there a workaround?

---

## [Space varying parameter in PDE with ModelingToolkit](https://discourse.julialang.org/t/space-varying-parameter-in-pde-with-modelingtoolkit/91897)

<div class="topic-metadata">

**Author:** [@touste](https://discourse.julialang.org/u/touste)\
**Replies:** 4\
**Last updated:** [December 20, 2022, 4:49pm UTC](https://discourse.julialang.org/t/space-varying-parameter-in-pde-with-modelingtoolkit/91897 "2022-12-20T16:49:39Z")

</div>

Hi all, I’m trying to solve a simple 1D heat equation. As the future objective is to identify some parameters of this equation, I use ModellingToolkit with MethodOfLines as showcased in the example of the MethodOfLines …

---

## [Why does BlueStyle do this?](https://discourse.julialang.org/t/why-does-bluestyle-do-this/91871)

<div class="topic-metadata">

**Author:** [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Replies:** 14\
**Last updated:** [December 20, 2022, 4:31pm UTC](https://discourse.julialang.org/t/why-does-bluestyle-do-this/91871 "2022-12-20T16:31:53Z")

</div>

I recently read through BlueStyle (and YASGuide). There are a few items that feel strange to me. I’ll probably conform and get used to it, but I could use some more convincing on why my way is worse. Why so vertical? …

---

## [Mutating Arrays in Training](https://discourse.julialang.org/t/mutating-arrays-in-training/91879)

<div class="topic-metadata">

**Author:** [@ChrisVL1](https://discourse.julialang.org/u/ChrisVL1)\
**Replies:** 1\
**Last updated:** [December 20, 2022, 7:45am UTC](https://discourse.julialang.org/t/mutating-arrays-in-training/91879 "2022-12-20T07:45:49Z")

</div>

I am writing a training function that requires a loop as my loss is the difference between call prices which I need to calculate for various strikes using a loop. However, this results in a mutating array, how do I get a…

---

## [Inconsistency in derivative computation in Symbolics.jl](https://discourse.julialang.org/t/inconsistency-in-derivative-computation-in-symbolics-jl/91880)

<div class="topic-metadata">

**Author:** [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Replies:** 1\
**Last updated:** [December 20, 2022, 7:43am UTC](https://discourse.julialang.org/t/inconsistency-in-derivative-computation-in-symbolics-jl/91880 "2022-12-20T07:43:03Z")

</div>

These two ways of computing the derivative in Symbolics return the same result, as expected: using Symbolics @variables k1,k2 julia\> Symbolics.derivative(^,(k1,k2),Val(1)) k2\*(k1^(k2 - 1)) julia\> Symbolics.derivative(…

---

## [Generator slow when passed as argument](https://discourse.julialang.org/t/generator-slow-when-passed-as-argument/91606)

<div class="topic-metadata">

**Author:** [@uniment](https://discourse.julialang.org/u/uniment)\
**Replies:** 6\
**Last updated:** [December 20, 2022, 3:02am UTC](https://discourse.julialang.org/t/generator-slow-when-passed-as-argument/91606 "2022-12-20T03:02:47Z")

</div>

(Julia 1.9.0-alpha1) Why is this? julia\> @btime let x=(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8) ns=propertynames(x) NamedTuple{ns}(map(n-\>getproperty(x,n), ns)) end 1.000 ns (0 allocations: 0 byt…

---

## [Type-Instability when calling \`fieldtypes\`](https://discourse.julialang.org/t/type-instability-when-calling-fieldtypes/91881)

<div class="topic-metadata">

**Author:** [@uniment](https://discourse.julialang.org/u/uniment)\
**Replies:** 0\
**Last updated:** [December 20, 2022, 1:05am UTC](https://discourse.julialang.org/t/type-instability-when-calling-fieldtypes/91881 "2022-12-20T01:05:21Z")

</div>

Is there a way to make fieldtypes not be type-unstable here? julia\> struct Foo{A,B} a::A; b::B end julia\> ft1(o::T) where T = Tuple(T.types) ft1 (generic function with 1 method) julia\> ft2(o::T) where T = fieldtypes(T…

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

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