# New to Julia

**URL:** https://discourse.julialang.org/c/first-steps/8.md?page=44

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

**Page:** 45

---

## [HOWTO: JSON3 read json path value as Custom type or Convert JSON3.Object as Custom type](https://discourse.julialang.org/t/howto-json3-read-json-path-value-as-custom-type-or-convert-json3-object-as-custom-type/115014)

<div class="topic-metadata">

**Author:** [@listenmmm](https://discourse.julialang.org/u/listenmmm)\
**Replies:** 8\
**Last updated:** [May 31, 2024, 3:00pm UTC](https://discourse.julialang.org/t/howto-json3-read-json-path-value-as-custom-type-or-convert-json3-object-as-custom-type/115014 "2024-05-31T15:00:37Z")

</div>

begin struct Book name price tags end StructTypes.StructType(::Type{Book}) = StructTypes.Struct() request\_body\_io = IOBuffer() response\_body\_io = IOBuffer() JSON3.write(request\_body\_io, Book("t…

---

## [How to read Download response body string?](https://discourse.julialang.org/t/how-to-read-download-response-body-string/114996)

<div class="topic-metadata">

**Author:** [@listenmmm](https://discourse.julialang.org/u/listenmmm)\
**Replies:** 1\
**Last updated:** [May 31, 2024, 6:38am UTC](https://discourse.julialang.org/t/how-to-read-download-response-body-string/114996 "2024-05-31T06:38:58Z")

</div>

code using Downloads begin response\_bpdy\_io = IOBuffer() response = request( "https://httpbin.org/ip", method="GET", headers=Dict("accept" =\> "application/json"), verbose=true, output=response\_b…

---

## [Issue with using Unicode in symbol names](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 8\
**Last updated:** [May 30, 2024, 10:16pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942 "2024-05-30T22:16:00Z")

</div>

julia\> 5 + 5 10 julia\> · = 5 5 julia\> · 5 julia\> · + · ERROR: ParseError: # Error @ REPL\[31\]:1:1 · + · ╙ ── not a unary operator Stacktrace: \[1\] top-level scope @ none:1 julia\>

---

## [Agent steps](https://discourse.julialang.org/t/agent-steps/114980)

<div class="topic-metadata">

**Author:** [@Dawit](https://discourse.julialang.org/u/Dawit)\
**Replies:** 0\
**Last updated:** [May 30, 2024, 7:15pm UTC](https://discourse.julialang.org/t/agent-steps/114980 "2024-05-30T19:15:17Z")

</div>

Hi Guys, I am new to julia… I was working on American football simulation and I tried to move agents/players with certain movement… for them to score and reset on the center position. Now i wanted to try… for the ball ca…

---

## [Custom prompt and introductory text in REPL](https://discourse.julialang.org/t/custom-prompt-and-introductory-text-in-repl/114943)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 3\
**Last updated:** [May 30, 2024, 5:05pm UTC](https://discourse.julialang.org/t/custom-prompt-and-introductory-text-in-repl/114943 "2024-05-30T17:05:33Z")

</div>

How to customize the REPL prompt and replace the introductory message of the REPL by putting appropriate code into the “startup.jl” script in “~/.julia/config” directory?

---

## [Help with CUDA Error](https://discourse.julialang.org/t/help-with-cuda-error/114946)

<div class="topic-metadata">

**Author:** [@19fitzna](https://discourse.julialang.org/u/19fitzna)\
**Replies:** 5\
**Last updated:** [May 30, 2024, 2:10pm UTC](https://discourse.julialang.org/t/help-with-cuda-error/114946 "2024-05-30T14:10:52Z")

</div>

Hello! I’m still relatively new to Julia so I apologize if this is a stupid question. I am currently trying to implement a GPU backend for training universal differential equations. I just updated to Julia 1.10.3, and h…

---

## [Random sampling with rand(Uniform(0,1), n)](https://discourse.julialang.org/t/random-sampling-with-rand-uniform-0-1-n/114962)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 4\
**Last updated:** [May 30, 2024, 12:07pm UTC](https://discourse.julialang.org/t/random-sampling-with-rand-uniform-0-1-n/114962 "2024-05-30T12:07:07Z")

</div>

Hello everyone, I’m trying to collect some random samples from Uniform distribution Uniform(0,1) . What I observe is that most of values are around 10^-1 range so like 0.1, 0.3, 0.7 something like that but it rarely hi…

---

## [Executing system commands "backtick-like" way in Julia?](https://discourse.julialang.org/t/executing-system-commands-backtick-like-way-in-julia/114890)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 18\
**Last updated:** [May 30, 2024, 1:31am UTC](https://discourse.julialang.org/t/executing-system-commands-backtick-like-way-in-julia/114890 "2024-05-30T01:31:41Z")

</div>

In Ruby I can put a shell command in backtick quotes and will get the printed output and the exit code as response. How to accomplish the same in Julia with as less prefix and postfix code wrapping the string of the shel…

---

## [Placing Unicode texts anywhere within Julia code](https://discourse.julialang.org/t/placing-unicode-texts-anywhere-within-julia-code/114888)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 3\
**Last updated:** [May 29, 2024, 11:01pm UTC](https://discourse.julialang.org/t/placing-unicode-texts-anywhere-within-julia-code/114888 "2024-05-29T23:01:20Z")

</div>

I am migrating from Python where I had been using triple quoted strings of two kinds to insert multi-line comments and one-line strings of both kinds which were all differently highlighted anywhere in the code as standal…

---

## [Using Quarto to create package documentation](https://discourse.julialang.org/t/using-quarto-to-create-package-documentation/102698)

<div class="topic-metadata">

**Author:** [@vituri](https://discourse.julialang.org/u/vituri)\
**Replies:** 12\
**Last updated:** [May 29, 2024, 8:41pm UTC](https://discourse.julialang.org/t/using-quarto-to-create-package-documentation/102698 "2024-05-29T20:41:55Z")

</div>

From what I’ve seem, Documenter.jl is almost the only tool used, because of macros like @docs, index generation, easy github actions and so on. However, coming from R, Quarto seems a much more natural choice to me. With …

---

## [Hosting pluto notebooks online - 2024](https://discourse.julialang.org/t/hosting-pluto-notebooks-online-2024/114920)

<div class="topic-metadata">

**Author:** [@user23804985096787](https://discourse.julialang.org/u/user23804985096787)\
**Replies:** 3\
**Last updated:** [May 29, 2024, 7:15pm UTC](https://discourse.julialang.org/t/hosting-pluto-notebooks-online-2024/114920 "2024-05-29T19:15:39Z")

</div>

this has been asked several times before, but the information seems out-of-date. I would like to run some small pluto notebooks that can be run interactively online without the person viewing it needing to install Julia. …

---

## [Mutable scalar in immutable object: the best alternative?](https://discourse.julialang.org/t/mutable-scalar-in-immutable-object-the-best-alternative/57401)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 11\
**Last updated:** [May 29, 2024, 3:33pm UTC](https://discourse.julialang.org/t/mutable-scalar-in-immutable-object-the-best-alternative/57401 "2024-05-29T15:33:40Z")

</div>

I found this old thread about the same thing, but that was before 1.0. Actually while writing this post I figured out most of the details… now I will post it anyway. If one has an immutable struct with many fields, and …

---

## [Efficiently extracting a column of a sparse matrix](https://discourse.julialang.org/t/efficiently-extracting-a-column-of-a-sparse-matrix/114904)

<div class="topic-metadata">

**Author:** [@gtgt](https://discourse.julialang.org/u/gtgt)\
**Replies:** 3\
**Last updated:** [May 29, 2024, 3:21pm UTC](https://discourse.julialang.org/t/efficiently-extracting-a-column-of-a-sparse-matrix/114904 "2024-05-29T15:21:04Z")

</div>

Given a sparse matrix S, how can I efficiently extract the ith column of S? I know I can use @view S.nzval\[S.colptr\[i\] : S.colptr\[i + 1\] - 1\] but it’s a bit clunky.

---

## [Simple neuron & backpropagation](https://discourse.julialang.org/t/simple-neuron-backpropagation/114896)

<div class="topic-metadata">

**Author:** [@younes](https://discourse.julialang.org/u/younes)\
**Replies:** 0\
**Last updated:** [May 29, 2024, 6:38am UTC](https://discourse.julialang.org/t/simple-neuron-backpropagation/114896 "2024-05-29T06:38:16Z")

</div>

Hello, I’m relatively new to Julia and decided to calculate the output of a neuron given specific inputs, weights, and bias using two methods: “manually” and with Flux.jl. You can check out my Pluto.jl notebook here: Bi…

---

## [Create a 1D flat array and 2D diagonal-offset/position view on all right-left diagonals to an NxM 2D array](https://discourse.julialang.org/t/create-a-1d-flat-array-and-2d-diagonal-offset-position-view-on-all-right-left-diagonals-to-an-nxm-2d-array/114868)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 21\
**Last updated:** [May 28, 2024, 11:05pm UTC](https://discourse.julialang.org/t/create-a-1d-flat-array-and-2d-diagonal-offset-position-view-on-all-right-left-diagonals-to-an-nxm-2d-array/114868 "2024-05-28T23:05:32Z")

</div>

I am struggling using Python numpy to reverse the right-left diagonals of an array and to convert them to a special diagonal items arrangement … How can this be done in Julia? Or what would be the simple formulas of obta…

---

## [Mandatory vs. optional arguments to functions](https://discourse.julialang.org/t/mandatory-vs-optional-arguments-to-functions/114854)

<div class="topic-metadata">

**Author:** [@Matthijs\_1971](https://discourse.julialang.org/u/Matthijs_1971)\
**Replies:** 2\
**Last updated:** [May 28, 2024, 9:07pm UTC](https://discourse.julialang.org/t/mandatory-vs-optional-arguments-to-functions/114854 "2024-05-28T21:07:43Z")

</div>

Code: #!/usr/bin/env julia f(x=0) = println("f(x=0): x ", x) f() f(1) println("methods(f)") println(methods(f)) println() f(x) = println("f(x) : x ", x) f() f(2) println("methods(f)") println(methods(f)) Outpu…

---

## [Combine function not naming column as cols =\> function =\> target\_cols implies](https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831)

<div class="topic-metadata">

**Author:** [@rhoxx](https://discourse.julialang.org/u/rhoxx)\
**Replies:** 7\
**Last updated:** [May 28, 2024, 3:50pm UTC](https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831 "2024-05-28T15:50:32Z")

</div>

Hi there I’m still new to Julia. Trying to figure out why some behavior is not as I would it expect to be. In the dataframes example for the split-apply-combine strategy here https://dataframes.juliadata.org/stable/man/…

---

## [Error Connecting Julia to Python Jupyter Notebook](https://discourse.julialang.org/t/error-connecting-julia-to-python-jupyter-notebook/109226)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 1\
**Last updated:** [May 28, 2024, 3:29pm UTC](https://discourse.julialang.org/t/error-connecting-julia-to-python-jupyter-notebook/109226 "2024-05-28T15:29:07Z")

</div>

When I run the code from a Python 3.6.9 Jupyter Notebook, the kernel dies: from julia.api import Julia jl = Julia(compiled\_modules=False) from julia import Main My goal is to have a Julia subroutine that will be calle…

---

## [Type parametrisation and the @agent macro](https://discourse.julialang.org/t/type-parametrisation-and-the-agent-macro/114846)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 1\
**Last updated:** [May 28, 2024, 3:14pm UTC](https://discourse.julialang.org/t/type-parametrisation-and-the-agent-macro/114846 "2024-05-28T15:14:22Z")

</div>

Is it possible to use type parametrisation with the @agent macro? This is what I’d like to do: @agent struct AnAgent(NoSpaceAgent){C} \<: AbstractAgent{C \<: FixedDecimal} balance::C end But this syntax clearly does no…

---

## [Accessing the constructor of a type as a function](https://discourse.julialang.org/t/accessing-the-constructor-of-a-type-as-a-function/114823)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 3\
**Last updated:** [May 28, 2024, 2:51pm UTC](https://discourse.julialang.org/t/accessing-the-constructor-of-a-type-as-a-function/114823 "2024-05-28T14:51:55Z")

</div>

Is there any way that I can get the construction function of a struct? What I want to do is the following: I have a struct Foo and 2 Worker structs: struct Foo worker\_creator::Function end mutable struct HardWorker…

---

## [SVG to PNG](https://discourse.julialang.org/t/svg-to-png/18643)

<div class="topic-metadata">

**Author:** [@wsrinin](https://discourse.julialang.org/u/wsrinin)\
**Replies:** 3\
**Last updated:** [May 27, 2024, 7:33am UTC](https://discourse.julialang.org/t/svg-to-png/18643 "2024-05-27T07:33:27Z")

</div>

Hello, Is there a package that allows me to convert SVG file to PNG file? Best,

---

## [Parallel with communication of Matrix(SMatrix(ComplexF64)) using MPI](https://discourse.julialang.org/t/parallel-with-communication-of-matrix-smatrix-complexf64-using-mpi/114765)

<div class="topic-metadata">

**Author:** [@Kohei\_Hattori](https://discourse.julialang.org/u/Kohei_Hattori)\
**Replies:** 0\
**Last updated:** [May 27, 2024, 6:32am UTC](https://discourse.julialang.org/t/parallel-with-communication-of-matrix-smatrix-complexf64-using-mpi/114765 "2024-05-27T06:32:03Z")

</div>

I am new to julia. I have a question about MPI parallel computing. I would like to communicate the matrices in each process as follows. The code I have created is shown below. I would like this code to send the matri…

---

## [How to Use Real and Complex Noises in One Problem?](https://discourse.julialang.org/t/how-to-use-real-and-complex-noises-in-one-problem/114718)

<div class="topic-metadata">

**Author:** [@Sepanta-Mssvn](https://discourse.julialang.org/u/Sepanta-Mssvn)\
**Replies:** 1\
**Last updated:** [May 25, 2024, 4:02pm UTC](https://discourse.julialang.org/t/how-to-use-real-and-complex-noises-in-one-problem/114718 "2024-05-25T16:02:06Z")

</div>

I would like to use both real and complex Weiner processes in one problem. For a simple example, suppose we have: using DifferentialEquations function Eq(du,u,p,t) du\[1\] = u\[1\] + u\[2\] du\[2\] = 2 \* u\[1\] end funct…

---

## [Understanding the behaviour of @. macro](https://discourse.julialang.org/t/understanding-the-behaviour-of-macro/114680)

<div class="topic-metadata">

**Author:** [@Janik](https://discourse.julialang.org/u/Janik)\
**Replies:** 5\
**Last updated:** [May 25, 2024, 12:47am UTC](https://discourse.julialang.org/t/understanding-the-behaviour-of-macro/114680 "2024-05-25T00:47:49Z")

</div>

Hi, I am very new to Julia and was playing around with @. (using Julia 1.10.3) and noticed that I can compute the expression 5 .\* rand(10) .+ 2 as expected, however when I use @. 5\*rand(10) + 2 it does not work and …

---

## [How do I use 'pchip' interpolation of Matlab in Julia code?](https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688)

<div class="topic-metadata">

**Author:** [@hyde](https://discourse.julialang.org/u/hyde)\
**Replies:** 1\
**Last updated:** [May 24, 2024, 5:29pm UTC](https://discourse.julialang.org/t/how-do-i-use-pchip-interpolation-of-matlab-in-julia-code/114688 "2024-05-24T17:29:34Z")

</div>

In Matlab, there is ‘pchip’ interpolation method. How do I can use ‘pchip’ interpolation by Julia code. I tried some guide such as ‘‘GitHub - gerlero/PCHIPInterpolation.jl: Monotonic cubic interpolation in Julia’’ foun…

---

## [Ignore Manifest.toml when testing a package](https://discourse.julialang.org/t/ignore-manifest-toml-when-testing-a-package/111003)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 3\
**Last updated:** [May 24, 2024, 4:04pm UTC](https://discourse.julialang.org/t/ignore-manifest-toml-when-testing-a-package/111003 "2024-05-24T16:04:30Z")

</div>

Hi, I am testing a local package with different version of Julia. And I always get the message: “The active manifest file has dependencies that were resolved with a different julia version. Unexpected behaviour may oc…

---

## [Add Tasks to Background Worker](https://discourse.julialang.org/t/add-tasks-to-background-worker/114595)

<div class="topic-metadata">

**Author:** [@stefanjwojcik](https://discourse.julialang.org/u/stefanjwojcik)\
**Replies:** 3\
**Last updated:** [May 23, 2024, 11:48am UTC](https://discourse.julialang.org/t/add-tasks-to-background-worker/114595 "2024-05-23T11:48:17Z")

</div>

I’m trying to create a worker who will pick up tasks from a global list and execute them without blocking the repl (i.e. the worker executes in the background). In the following MWE, I’d expect that adding tasks to the w…

---

## [Shannon wavelet entropy](https://discourse.julialang.org/t/shannon-wavelet-entropy/114319)

<div class="topic-metadata">

**Author:** [@ahrensma](https://discourse.julialang.org/u/ahrensma)\
**Replies:** 3\
**Last updated:** [May 23, 2024, 7:31am UTC](https://discourse.julialang.org/t/shannon-wavelet-entropy/114319 "2024-05-23T07:31:31Z")

</div>

Hello, I look for a function similar to the wentropy function in the Wavelet Toolbox of Matlab. In an older code I used to following form: H = -wentropy( DataArray , 'shannon' ); I look in several packages (Wavelet.jl…

---

## [How to access values in TimeArrays cells](https://discourse.julialang.org/t/how-to-access-values-in-timearrays-cells/55593)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 3:40am UTC](https://discourse.julialang.org/t/how-to-access-values-in-timearrays-cells/55593 "2024-05-23T03:40:35Z")

</div>

Following what can be done in DataFrames, for example, using DataFrames, TimeSeries A = \[1,2,3\] B = \[3,4,5\] C = DataFrame(A=A, B=B) C\[1,2\] == 3 # true typeof(C\[1,2\]) # Int64 I am trying to access values in cells from a…

---

## [Memory allocations](https://discourse.julialang.org/t/memory-allocations/114499)

<div class="topic-metadata">

**Author:** [@LucasMontoya4](https://discourse.julialang.org/u/LucasMontoya4)\
**Replies:** 2\
**Last updated:** [May 22, 2024, 4:25pm UTC](https://discourse.julialang.org/t/memory-allocations/114499 "2024-05-22T16:25:08Z")

</div>

Hi there, I was wondering why the line @allocated A = 100 gives 0, whereas @allocated B = \[1,2,3,4,5\] gives 96. Both can result in a completely fresh REPL, so why does defining A = 100 not use any memory? Surely the info…

[Previous page](https://discourse.julialang.org/c/first-steps/8.md?page=43)

[Next page](https://discourse.julialang.org/c/first-steps/8.md?page=45)
