# New to Julia

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

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

**Page:** 59

---

## [Replace lines of file A using advanced regex and write to file B](https://discourse.julialang.org/t/replace-lines-of-file-a-using-advanced-regex-and-write-to-file-b/94362)

<div class="topic-metadata">

**Author:** [@Johannes\_Schweichhar](https://discourse.julialang.org/u/Johannes_Schweichhar)\
**Replies:** 16\
**Last updated:** [January 10, 2024, 10:23pm UTC](https://discourse.julialang.org/t/replace-lines-of-file-a-using-advanced-regex-and-write-to-file-b/94362 "2024-01-10T22:23:52Z")

</div>

Hi, I 've tried for quite some time now to replace a regex pattern in a large file and to write the result to second file. The replace expression using a dummy string works as expected. With the files I always end up wi…

---

## [Overlaying a grid of colored squares onto a map in GMT](https://discourse.julialang.org/t/overlaying-a-grid-of-colored-squares-onto-a-map-in-gmt/108547)

<div class="topic-metadata">

**Author:** [@yalonso](https://discourse.julialang.org/u/yalonso)\
**Replies:** 5\
**Last updated:** [January 10, 2024, 7:42pm UTC](https://discourse.julialang.org/t/overlaying-a-grid-of-colored-squares-onto-a-map-in-gmt/108547 "2024-01-10T19:42:03Z")

</div>

Hello! I am new to Julia and GMT and am looking to see if it’s possible to overlay a grid (in which i define how large each box should be and the color it should be) on top of a plot of a certain region of the US. funct…

---

## [Why does this example usage of digits! not work?](https://discourse.julialang.org/t/why-does-this-example-usage-of-digits-not-work/108633)

<div class="topic-metadata">

**Author:** [@r32679](https://discourse.julialang.org/u/r32679)\
**Replies:** 2\
**Last updated:** [January 10, 2024, 4:18pm UTC](https://discourse.julialang.org/t/why-does-this-example-usage-of-digits-not-work/108633 "2024-01-10T16:18:22Z")

</div>

used this example julia\> arr=\[0,0,0\]; julia\>digits!(arr,123,10) Get this output from Julia. ERROR: LoadError: no method matching digits!(::Vector\[Int64}, ::Int64, ::Int64)

---

## [Expr to String conversion](https://discourse.julialang.org/t/expr-to-string-conversion/4118)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 4\
**Last updated:** [January 10, 2024, 7:57am UTC](https://discourse.julialang.org/t/expr-to-string-conversion/4118 "2024-01-10T07:57:45Z")

</div>

Is there a function that converts an expression or symbol to a String representation?

---

## [Clean way to use mean value with distributions](https://discourse.julialang.org/t/clean-way-to-use-mean-value-with-distributions/108580)

<div class="topic-metadata">

**Author:** [@lenz](https://discourse.julialang.org/u/lenz)\
**Replies:** 0\
**Last updated:** [January 9, 2024, 6:03pm UTC](https://discourse.julialang.org/t/clean-way-to-use-mean-value-with-distributions/108580 "2024-01-09T18:03:30Z")

</div>

I have a model that is called with a strut with all the arguments (with units) needed. I would like to use this model to do uncertainty analysis by setting some of these values to a distribution. I would like to be able…

---

## [How to delete the number of lines plotted in the graph](https://discourse.julialang.org/t/how-to-delete-the-number-of-lines-plotted-in-the-graph/108541)

<div class="topic-metadata">

**Author:** [@kim1](https://discourse.julialang.org/u/kim1)\
**Replies:** 6\
**Last updated:** [January 9, 2024, 5:01pm UTC](https://discourse.julialang.org/t/how-to-delete-the-number-of-lines-plotted-in-the-graph/108541 "2024-01-09T17:01:40Z")

</div>

Hi guys Im trying to plot my graph but it keep on increasing the number of line plotted each time. Plot{Plots.GRBackend() n=5} I want only n=2. How do I delete the unnecessary lines.

---

## [How to apply an in-place function to a slice of a vector?](https://discourse.julialang.org/t/how-to-apply-an-in-place-function-to-a-slice-of-a-vector/108520)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 11\
**Last updated:** [January 9, 2024, 11:02am UTC](https://discourse.julialang.org/t/how-to-apply-an-in-place-function-to-a-slice-of-a-vector/108520 "2024-01-09T11:02:07Z")

</div>

I want to have an in-place function that takes a vector as an argument and applies another in-place function to a subarray (in general sense). How do I do this? function f!(du, u) println("\\nf called") @show u …

---

## [How to plot a mirror graph from the one created](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394)

<div class="topic-metadata">

**Author:** [@kim1](https://discourse.julialang.org/u/kim1)\
**Replies:** 27\
**Last updated:** [January 8, 2024, 9:56pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394 "2024-01-08T21:56:02Z")

</div>

Hi does anyone know how to plot my already plotted graph by mirroring it on the negative value?

---

## [Column types in DataFrames](https://discourse.julialang.org/t/column-types-in-dataframes/108532)

<div class="topic-metadata">

**Author:** [@vsoler](https://discourse.julialang.org/u/vsoler)\
**Replies:** 3\
**Last updated:** [January 8, 2024, 7:14pm UTC](https://discourse.julialang.org/t/column-types-in-dataframes/108532 "2024-01-08T19:14:09Z")

</div>

I have a big DataFrame named df. I want to create, from it, another DataFrame with 2 columns: the first column should contain the column names of df. The second column should contain its column types. I have tried this…

---

## [Install SSL/TLS Libraries in Julia?](https://discourse.julialang.org/t/install-ssl-tls-libraries-in-julia/108521)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 4\
**Last updated:** [January 8, 2024, 6:38pm UTC](https://discourse.julialang.org/t/install-ssl-tls-libraries-in-julia/108521 "2024-01-08T18:38:56Z")

</div>

using HTTP using JSON function getIPInfo() url = "https://ipapi.co/json" response = HTTP.get(url) if response.status == 200 data = JSON.parse(String(response.body)) println("IP Information:"…

---

## [Precompilation issue with DifferentialEquations.jl](https://discourse.julialang.org/t/precompilation-issue-with-differentialequations-jl/108517)

<div class="topic-metadata">

**Author:** [@sandeeptegar](https://discourse.julialang.org/u/sandeeptegar)\
**Replies:** 16\
**Last updated:** [January 8, 2024, 4:25pm UTC](https://discourse.julialang.org/t/precompilation-issue-with-differentialequations-jl/108517 "2024-01-08T16:25:39Z")

</div>

I am using julia-1.10.0. I am using julia remotely on the Rocky 9 VM. I am getting the following error in the pre-compilation of the DifferentialEquations.jl package: PkgPrecompileError: The following 1 direct depende…

---

## [How to delete a function?](https://discourse.julialang.org/t/how-to-delete-a-function/108422)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 7\
**Last updated:** [January 8, 2024, 1:47pm UTC](https://discourse.julialang.org/t/how-to-delete-a-function/108422 "2024-01-08T13:47:15Z")

</div>

I want to experiment with a small function. Before defining it, I want to make sure that the function name is not used before, or it does not exist in the workspace. How can I do it? In Matlab, it is simple with ‘clear’ …

---

## [Mutating arrays inside function](https://discourse.julialang.org/t/mutating-arrays-inside-function/108431)

<div class="topic-metadata">

**Author:** [@pratikvn](https://discourse.julialang.org/u/pratikvn)\
**Replies:** 13\
**Last updated:** [January 8, 2024, 6:30am UTC](https://discourse.julialang.org/t/mutating-arrays-inside-function/108431 "2024-01-08T06:30:09Z")

</div>

Hello, I am new to Julia and just trying out things and ran into something that I found unintuitive and wanted to understand the canonical way. Basically, I am trying to pass in an array to a function and have the func…

---

## [Some Fine YouTube Creators Teaching Julia](https://discourse.julialang.org/t/some-fine-youtube-creators-teaching-julia/108357)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 2\
**Last updated:** [January 5, 2024, 7:38pm UTC](https://discourse.julialang.org/t/some-fine-youtube-creators-teaching-julia/108357 "2024-01-05T19:38:21Z")

</div>

I’m relatively new to this forum, but I’ve already learned a great deal from those who have taken the time to answer my questions. I’ve also learned from those outside the immediate community here. I’d like to draw atten…

---

## [PProf doesnt open in the web](https://discourse.julialang.org/t/pprof-doesnt-open-in-the-web/107492)

<div class="topic-metadata">

**Author:** [@Helectus](https://discourse.julialang.org/u/Helectus)\
**Replies:** 1\
**Last updated:** [January 6, 2024, 4:43pm UTC](https://discourse.julialang.org/t/pprof-doesnt-open-in-the-web/107492 "2024-01-06T16:43:47Z")

</div>

I try to use PProf but it doesnt seem to open the ui in firefox. The error message is profile.pb.gz: malformed profile: found location with reserved id=0 pprof: failed to fetch any source profiles I used @profile my\_f…

---

## [Return (; a, b )](https://discourse.julialang.org/t/return-a-b/108388)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 4\
**Last updated:** [January 5, 2024, 8:54pm UTC](https://discourse.julialang.org/t/return-a-b/108388 "2024-01-05T20:54:57Z")

</div>

This is the last line of a function. What does the ; mean here? I know return (a,b) is to return a tuple. But what does return (; a,b) mean?

---

## [Difference between 'x.=y' and 'x=y'](https://discourse.julialang.org/t/difference-between-x-y-and-x-y/108366)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 6\
**Last updated:** [January 5, 2024, 7:12pm UTC](https://discourse.julialang.org/t/difference-between-x-y-and-x-y/108366 "2024-01-05T19:12:36Z")

</div>

I see codes like this x.= x./maximum(abs.(x)) Here x is a vector. Personally, I would write x = x./maximum(abs.(x)) Is there any significant difference between the two?

---

## [Function or struct？](https://discourse.julialang.org/t/function-or-struct/108376)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 3\
**Last updated:** [January 5, 2024, 12:45pm UTC](https://discourse.julialang.org/t/function-or-struct/108376 "2024-01-05T12:45:58Z")

</div>

struct MyType{T} label::T x::Float64 y::Float64 end function MyType(; label = 1000, x = 0, y = 0) return MyType(label, x, y) end I am a bit confused. Here we have a function and a struct, both of wh…

---

## [Function at the beginning of a script or at the end?](https://discourse.julialang.org/t/function-at-the-beginning-of-a-script-or-at-the-end/108372)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 2\
**Last updated:** [January 5, 2024, 7:29am UTC](https://discourse.julialang.org/t/function-at-the-beginning-of-a-script-or-at-the-end/108372 "2024-01-05T07:29:56Z")

</div>

x = rand(5) x .=f.(x) function f(x) return 2 \* x end This is a test script. In vs code, I got an error /ERROR: AUndefVarError: \`f\` not definedn Stacktrace:a c o\[1\]n dtop-level scopea / @S cUntitled-3:5ri julia\> …

---

## [Inline Math Rules / Reference / Cheat Sheet?](https://discourse.julialang.org/t/inline-math-rules-reference-cheat-sheet/108315)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 17\
**Last updated:** [January 4, 2024, 8:48pm UTC](https://discourse.julialang.org/t/inline-math-rules-reference-cheat-sheet/108315 "2024-01-04T20:48:29Z")

</div>

Is there a reference page somewhere in the Julia documentation with the rules for properly writing inline math strings? The string is then able to be converted with Latexify and used with Markdown to graphically render e…

---

## [Using REPL vs using Terminal and .jl file?](https://discourse.julialang.org/t/using-repl-vs-using-terminal-and-jl-file/107653)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 9\
**Last updated:** [January 4, 2024, 5:28pm UTC](https://discourse.julialang.org/t/using-repl-vs-using-terminal-and-jl-file/107653 "2024-01-04T17:28:38Z")

</div>

\# Define the first two Fibonacci numbers a, b = 0, 1 # Print the first two numbers println(a) println(b) # Loop until the current number is greater than 50 while b \<= 50 # Calculate the next Fibonacci number c = a…

---

## [Redefining == operator doesn't behave expectedly](https://discourse.julialang.org/t/redefining-operator-doesnt-behave-expectedly/108303)

<div class="topic-metadata">

**Author:** [@Joslacrosse](https://discourse.julialang.org/u/Joslacrosse)\
**Replies:** 4\
**Last updated:** [January 4, 2024, 7:18am UTC](https://discourse.julialang.org/t/redefining-operator-doesnt-behave-expectedly/108303 "2024-01-04T07:18:55Z")

</div>

I have a problem with a coding execise from Exercism, i habe been trying to solve it for some hours now I think the problem lies with the connectd == and != as if i tests the statements individually they work out. Does…

---

## [Julia environment falsely detected in a Quarto/Python project](https://discourse.julialang.org/t/julia-environment-falsely-detected-in-a-quarto-python-project/108331)

<div class="topic-metadata">

**Author:** [@EmiliaJarochowska](https://discourse.julialang.org/u/EmiliaJarochowska)\
**Replies:** 0\
**Last updated:** [January 4, 2024, 6:56am UTC](https://discourse.julialang.org/t/julia-environment-falsely-detected-in-a-quarto-python-project/108331 "2024-01-04T06:56:45Z")

</div>

Hello, probably a silly problem: I use Julia in other projects, but in one that has nothing to do with Julia (it’s a poetry & pipenv venv with Quarto files written in Python and some Python scripts to manage that project…

---

## [Enable Parallel Processing of Garbage Collections](https://discourse.julialang.org/t/enable-parallel-processing-of-garbage-collections/108308)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 11\
**Last updated:** [January 3, 2024, 10:47pm UTC](https://discourse.julialang.org/t/enable-parallel-processing-of-garbage-collections/108308 "2024-01-03T22:47:05Z")

</div>

Here is my code: using IJulia installkernel("Julia (4 threads)", env=Dict("JULIA\_NUM\_THREADS"=\>"4")) Threads.nthreads() This code creates a new kernel with multiple threads and works How can I modify this kernel so th…

---

## [Mutating function parameters](https://discourse.julialang.org/t/mutating-function-parameters/108268)

<div class="topic-metadata">

**Author:** [@TimG](https://discourse.julialang.org/u/TimG)\
**Replies:** 8\
**Last updated:** [January 2, 2024, 7:48pm UTC](https://discourse.julialang.org/t/mutating-function-parameters/108268 "2024-01-02T19:48:12Z")

</div>

using DataFrames function doit!(flag, df) if flag==true flag=false end if df\[1, :flag\]==true df\[1, :flag\]=false end println("Within doit, flag=",flag,", df=",df\[1, :flag\]) end functi…

---

## [Taking gradients of a matrix exponential](https://discourse.julialang.org/t/taking-gradients-of-a-matrix-exponential/107865)

<div class="topic-metadata">

**Author:** [@Bizzi](https://discourse.julialang.org/u/Bizzi)\
**Replies:** 10\
**Last updated:** [January 2, 2024, 3:48pm UTC](https://discourse.julialang.org/t/taking-gradients-of-a-matrix-exponential/107865 "2024-01-02T15:48:45Z")

</div>

I’m having trouble differentiating simple matrix exponentials. ForwardDiff and ReverseDiff can’t really do it, while Zygote’s result is type-unstable. using Zygote, ForwardDiff, ReverseDiff M = rand(2,2) ReverseDiff.gr…

---

## [From Julia Doc - 5. Creating Package - Pkg not found after Activating?](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067)

<div class="topic-metadata">

**Author:** [@benslinux](https://discourse.julialang.org/u/benslinux)\
**Replies:** 8\
**Last updated:** [January 2, 2024, 9:23am UTC](https://discourse.julialang.org/t/from-julia-doc-5-creating-package-pkg-not-found-after-activating/108067 "2024-01-02T09:23:11Z")

</div>

Sometimes I generate a pkg, then activate, then import and it works fine. Other times I get the msg - pkg not found and it’s right there in the directory I’m in. It’s such a simple process, I don’t understand what’s chan…

---

## [Swap the two largest elements in a vector](https://discourse.julialang.org/t/swap-the-two-largest-elements-in-a-vector/108234)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 13\
**Last updated:** [January 2, 2024, 7:34am UTC](https://discourse.julialang.org/t/swap-the-two-largest-elements-in-a-vector/108234 "2024-01-02T07:34:40Z")

</div>

Hello, good afternoon and Happy new Year. I would like to know how I can swap the two largest elements in a vector like \[1, 2, 3, 4, 5\]

---

## [Meaning of 'x-\>a' in plotting](https://discourse.julialang.org/t/meaning-of-x-a-in-plotting/108241)

<div class="topic-metadata">

**Author:** [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Replies:** 1\
**Last updated:** [January 2, 2024, 2:51am UTC](https://discourse.julialang.org/t/meaning-of-x-a-in-plotting/108241 "2024-01-02T02:51:48Z")

</div>

This is from some script: plot!(x-\>se.mean, df.steps\[steps\_equilibrate+1:end\], ribbon=se.err, label="shift mean") What does the syntax ‘-\>’ mean here?

---

## [How to mitigate bad performance of eigvals from LinearAlgebra](https://discourse.julialang.org/t/how-to-mitigate-bad-performance-of-eigvals-from-linearalgebra/108210)

<div class="topic-metadata">

**Author:** [@Paradox](https://discourse.julialang.org/u/Paradox)\
**Replies:** 3\
**Last updated:** [January 1, 2024, 1:11am UTC](https://discourse.julialang.org/t/how-to-mitigate-bad-performance-of-eigvals-from-linearalgebra/108210 "2024-01-01T01:11:41Z")

</div>

Dear all, I am trying to rewrite my Matlab code that calculates certain band structure to Julia. Unfortunately, I am unable to get close to the performance of Matlab code for some reason that I don’t understand. I will …

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

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