# New to Julia

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

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

**Page:** 28

---

## [Closures and type inference](https://discourse.julialang.org/t/closures-and-type-inference/123026)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 10\
**Last updated:** [November 26, 2024, 3:44am UTC](https://discourse.julialang.org/t/closures-and-type-inference/123026 "2024-11-26T03:44:51Z")

</div>

Hi there, I am reading through some Julia learning material and I had a question that someone here might be able to help with. The example given reads: function add\_n\_fn(n) function \_add\_n(x) return x+n e…

---

## [How does Julia parse \`return\`?](https://discourse.julialang.org/t/how-does-julia-parse-return/123044)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 6\
**Last updated:** [November 25, 2024, 3:42pm UTC](https://discourse.julialang.org/t/how-does-julia-parse-return/123044 "2024-11-25T15:42:08Z")

</div>

This question comes about after I had been using the JuliaFormatter.jl package to format some existing code. Compare the following 4 functions: function example() return end function example() return if a …

---

## [How to log to file with a customized log format?](https://discourse.julialang.org/t/how-to-log-to-file-with-a-customized-log-format/123021)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 9\
**Last updated:** [November 25, 2024, 2:20pm UTC](https://discourse.julialang.org/t/how-to-log-to-file-with-a-customized-log-format/123021 "2024-11-25T14:20:04Z")

</div>

I’m currently trying to build a logging demonstration using the JuliaLogging components (standard library + a few seemingly very standard packages). https://julialogging.github.io/ I may be wrong, however I think ther…

---

## [@assert alternatives?](https://discourse.julialang.org/t/assert-alternatives/24775)

<div class="topic-metadata">

**Author:** [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Replies:** 27\
**Last updated:** [November 25, 2024, 11:38am UTC](https://discourse.julialang.org/t/assert-alternatives/24775 "2024-11-25T11:38:10Z")

</div>

AFAIK there is no way yet to globally disable @assert with a compiler switch, even if doing so was already considered in the past (here and here, for example). While this is not done (as I do like to believe some day som…

---

## [Variable definition like C++](https://discourse.julialang.org/t/variable-definition-like-c/123038)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 7\
**Last updated:** [November 25, 2024, 8:53am UTC](https://discourse.julialang.org/t/variable-definition-like-c/123038 "2024-11-25T08:53:28Z")

</div>

Hello, In the C++ programming language, the definition of a variable is as follows: int res = 1; How is this done in Julia? Thank you.

---

## [Factorial program](https://discourse.julialang.org/t/factorial-program/123010)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 4\
**Last updated:** [November 25, 2024, 6:55am UTC](https://discourse.julialang.org/t/factorial-program/123010 "2024-11-25T06:55:22Z")

</div>

Hello, I know that Julia has a function called factorial. I have written a program as follows to do this: function fact(a) F = 1 for n = 1 : (a - 1) F = F \* (n + 1) println(F) end end Is it…

---

## [\`using\` and \`import\` can load files from the CWD? Surprising because it's not documented?](https://discourse.julialang.org/t/using-and-import-can-load-files-from-the-cwd-surprising-because-its-not-documented/122851)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 10\
**Last updated:** [November 24, 2024, 5:43pm UTC](https://discourse.julialang.org/t/using-and-import-can-load-files-from-the-cwd-surprising-because-its-not-documented/122851 "2024-11-24T17:43:46Z")

</div>

A colleague of mine has just noticed some behavior relating to using and import which we found surprising. include will load a file from disk and (effectively) insert the code at the point where the include line ran. W…

---

## [Macro for merging namedtuples and add suffixes in a type stable way](https://discourse.julialang.org/t/macro-for-merging-namedtuples-and-add-suffixes-in-a-type-stable-way/122975)

<div class="topic-metadata">

**Author:** [@ssdfg](https://discourse.julialang.org/u/ssdfg)\
**Replies:** 3\
**Last updated:** [November 24, 2024, 2:35pm UTC](https://discourse.julialang.org/t/macro-for-merging-namedtuples-and-add-suffixes-in-a-type-stable-way/122975 "2024-11-24T14:35:52Z")

</div>

I’m trying to create a macro that will merge named tuples and change the key names by adding suffixes, in a way that’s type stable. Suppose that it’s guaranteed that nt1 and nt2 are the same type of named tuples, i.e. t…

---

## [Chaining errors](https://discourse.julialang.org/t/chaining-errors/122984)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 2\
**Last updated:** [November 24, 2024, 11:45am UTC](https://discourse.julialang.org/t/chaining-errors/122984 "2024-11-24T11:45:49Z")

</div>

When a dictionary cannot retrieve values it shows two error types, is it making a kind of chaining or is it just inside the error message? LoadError: KeyError: key "d" not found

---

## [KrylovKit svdsolve not working](https://discourse.julialang.org/t/krylovkit-svdsolve-not-working/122993)

<div class="topic-metadata">

**Author:** [@EZ\_Money](https://discourse.julialang.org/u/EZ_Money)\
**Replies:** 3\
**Last updated:** [November 24, 2024, 7:07am UTC](https://discourse.julialang.org/t/krylovkit-svdsolve-not-working/122993 "2024-11-24T07:07:14Z")

</div>

Hi! I’m having a little trouble understanding why svdsolve isn’t working- I can’t seem to find my error. I’m running using SparseArrays using LinearAlgebra import LinearMaps import KrylovKit A = \[1 0; 0 1\] Lambda,Phi,…

---

## [How to solve the problem that the default installation path of the package is on the C drive??](https://discourse.julialang.org/t/how-to-solve-the-problem-that-the-default-installation-path-of-the-package-is-on-the-c-drive/122862)

<div class="topic-metadata">

**Author:** [@tiger\_Zhang](https://discourse.julialang.org/u/tiger_Zhang)\
**Replies:** 5\
**Last updated:** [November 23, 2024, 9:13pm UTC](https://discourse.julialang.org/t/how-to-solve-the-problem-that-the-default-installation-path-of-the-package-is-on-the-c-drive/122862 "2024-11-23T21:13:52Z")

</div>

How to solve the problem that the default installation path of the package is on the C drive? What are the issues with changing an environment variable to change the default installation path? I added two new system env…

---

## [Issues with continuation in BifurcationKit](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852)

<div class="topic-metadata">

**Author:** [@mmplac14](https://discourse.julialang.org/u/mmplac14)\
**Replies:** 11\
**Last updated:** [November 23, 2024, 1:19pm UTC](https://discourse.julialang.org/t/issues-with-continuation-in-bifurcationkit/122852 "2024-11-23T13:19:25Z")

</div>

Hi! I am new to Julia and BifurcationKit. I am trying to perform a bifurcation analysis of the Jansen-Rit model as was done by Grimbert and Faugueras but I keep running into this error when calling continuation The fun…

---

## [Get vs get!](https://discourse.julialang.org/t/get-vs-get/122985)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 3\
**Last updated:** [November 23, 2024, 11:53am UTC](https://discourse.julialang.org/t/get-vs-get/122985 "2024-11-23T11:53:49Z")

</div>

I do not know what could get! do to an object. Shouldn’t a get function be non-transformative of the input? I am accesing a value…

---

## [Return of split](https://discourse.julialang.org/t/return-of-split/122987)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 6\
**Last updated:** [November 23, 2024, 11:34am UTC](https://discourse.julialang.org/t/return-of-split/122987 "2024-11-23T11:34:21Z")

</div>

I was using split(str,separator) and it returned SubString (I verified it with typeof) and wa using the result in later functions: function instruct\_processor(db::Dict,op::String) arr=split(op," ",limit=2) print…

---

## [RigidBodyDynamics.jl - Fixed joint creation not working?](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719)

<div class="topic-metadata">

**Author:** [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Replies:** 2\
**Last updated:** [November 23, 2024, 11:25am UTC](https://discourse.julialang.org/t/rigidbodydynamics-jl-fixed-joint-creation-not-working/122719 "2024-11-23T11:25:16Z")

</div>

What is the correct syntax for creating a Fixed Joint, so it can be added to a Mechanism? A Revolute Joint is created by revolute\_joint = Joint("revolute\_joint", Revolute(axis) ) but a Fixed Joint I can’t get to accep…

---

## [About the type constraint of \`where\`](https://discourse.julialang.org/t/about-the-type-constraint-of-where/122958)

<div class="topic-metadata">

**Author:** [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Replies:** 8\
**Last updated:** [November 22, 2024, 2:46pm UTC](https://discourse.julialang.org/t/about-the-type-constraint-of-where/122958 "2024-11-22T14:46:03Z")

</div>

This post was originally asked at 参数化方法的疑问 - 语言特性及语义 - Julia中文社区 Based on the doc at Methods · The Julia Language : julia\> function myappend(v::Vector{T}, x::T) where {T} return \[v..., x\] end myappend…

---

## [Convert Union{Missing, String31} to DateTime](https://discourse.julialang.org/t/convert-union-missing-string31-to-datetime/122952)

<div class="topic-metadata">

**Author:** [@Sounak\_Ghosh](https://discourse.julialang.org/u/Sounak_Ghosh)\
**Replies:** 3\
**Last updated:** [November 22, 2024, 2:02pm UTC](https://discourse.julialang.org/t/convert-union-missing-string31-to-datetime/122952 "2024-11-22T14:02:44Z")

</div>

I have dataframe with a column which has some string values and some missing values. I wanted to convert this column into a DataTime column. I have used the following code df.dt = DateTime.(df.dt, dateformat"yyyy-mm-dd…

---

## [PhyloPlots](https://discourse.julialang.org/t/phyloplots/122916)

<div class="topic-metadata">

**Author:** [@jtolopka](https://discourse.julialang.org/u/jtolopka)\
**Replies:** 2\
**Last updated:** [November 22, 2024, 1:14pm UTC](https://discourse.julialang.org/t/phyloplots/122916 "2024-11-22T13:14:10Z")

</div>

Hi everyone, I’m encountering an issue when trying to precompile the “PhyloPlots” package in Julia. The image shows the error I’m getting. Has anyone encountered this issue, or can you suggest steps I might take to r…

---

## [State of real time DSP?](https://discourse.julialang.org/t/state-of-real-time-dsp/122934)

<div class="topic-metadata">

**Author:** [@RIU7](https://discourse.julialang.org/u/RIU7)\
**Replies:** 2\
**Last updated:** [November 22, 2024, 9:02am UTC](https://discourse.julialang.org/t/state-of-real-time-dsp/122934 "2024-11-22T09:02:06Z")

</div>

Hey guys, I’m interested in learning Julia, specifically for processing and visualizing signals and data. I myself am a C programmer, which is a lovely language but I’m in dire need of a simpler one for scripting, and I …

---

## [Simple machine learning example](https://discourse.julialang.org/t/simple-machine-learning-example/122912)

<div class="topic-metadata">

**Author:** [@ohm](https://discourse.julialang.org/u/ohm)\
**Replies:** 1\
**Last updated:** [November 21, 2024, 11:28pm UTC](https://discourse.julialang.org/t/simple-machine-learning-example/122912 "2024-11-21T23:28:36Z")

</div>

Hello, all, this is my first Julia question. Apologies is my formatting is off or if I am posting in the wrong place. My Julia journey started with the book Tanmay Teaches: Julia for beginners, which is a nice intro for…

---

## [Why are there all these strange stumbling blocks in Julia?](https://discourse.julialang.org/t/why-are-there-all-these-strange-stumbling-blocks-in-julia/92644)

<div class="topic-metadata">

**Author:** [@Sandjan](https://discourse.julialang.org/u/Sandjan)\
**Replies:** 89\
**Last updated:** [November 21, 2024, 12:41pm UTC](https://discourse.julialang.org/t/why-are-there-all-these-strange-stumbling-blocks-in-julia/92644 "2024-11-21T12:41:32Z")

</div>

I have programmed in Python so far and find the Python syntax very convenient. When learning Julia I constantly notice things that I can not understand: Why is there no short and simple floor division operator like in P…

---

## [How do we compute the gradient and Laplacian of a neural network using GPU?](https://discourse.julialang.org/t/how-do-we-compute-the-gradient-and-laplacian-of-a-neural-network-using-gpu/122728)

<div class="topic-metadata">

**Author:** [@aligurbu](https://discourse.julialang.org/u/aligurbu)\
**Replies:** 9\
**Last updated:** [November 19, 2024, 6:00pm UTC](https://discourse.julialang.org/t/how-do-we-compute-the-gradient-and-laplacian-of-a-neural-network-using-gpu/122728 "2024-11-19T18:00:10Z")

</div>

Hello everyone, I managed to compute the gradient and Laplacian of a neural network in CPU and tried to calculate these quantities in GPU but could not figure out how to do it. The example of the code that I am working…

---

## [How to find out which files are loaded by the Julia startup process?](https://discourse.julialang.org/t/how-to-find-out-which-files-are-loaded-by-the-julia-startup-process/122811)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 2\
**Last updated:** [November 19, 2024, 4:18pm UTC](https://discourse.julialang.org/t/how-to-find-out-which-files-are-loaded-by-the-julia-startup-process/122811 "2024-11-19T16:18:26Z")

</div>

I thought this info was in the documentation, but now I don’t seem to be able to find it. Is there a way to reverse-engineer which files have been loaded by Julia at startup? Normally, a user would expect the startup.j…

---

## [Julia Logging frameworks - Several options but no consensus?](https://discourse.julialang.org/t/julia-logging-frameworks-several-options-but-no-consensus/122672)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 6\
**Last updated:** [November 19, 2024, 2:08pm UTC](https://discourse.julialang.org/t/julia-logging-frameworks-several-options-but-no-consensus/122672 "2024-11-19T14:08:49Z")

</div>

There has been a dedicated page for Julia logging since 2021. https://julialogging.github.io/ I have been trying to figure out if there now an established consensus on which logging framework should be used with Julia…

---

## [How to read a line character by character?](https://discourse.julialang.org/t/how-to-read-a-line-character-by-character/122734)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 15\
**Last updated:** [November 19, 2024, 11:53am UTC](https://discourse.julialang.org/t/how-to-read-a-line-character-by-character/122734 "2024-11-19T11:53:02Z")

</div>

Hello, I have a file as follows: 1 2 3 4 5 6 7 8 9 10 I want to calculate the sum of the above numbers. With a command like below I read a whole line and not individual numbers: inn = open("input.txt", "r") inp = rea…

---

## [Does CSV.read allow another process to keep writing to file?](https://discourse.julialang.org/t/does-csv-read-allow-another-process-to-keep-writing-to-file/122656)

<div class="topic-metadata">

**Author:** [@japhir](https://discourse.julialang.org/u/japhir)\
**Replies:** 6\
**Last updated:** [November 19, 2024, 10:00am UTC](https://discourse.julialang.org/t/does-csv-read-allow-another-process-to-keep-writing-to-file/122656 "2024-11-19T10:00:19Z")

</div>

I’m running a pretty expensive job on a cluster. This generates plaintext output files by appending new lines with data regularly (roughly once every second or so). I’ve written some julia code to perform quick visualiz…

---

## [How to create a \`Union\` value/literal?](https://discourse.julialang.org/t/how-to-create-a-union-value-literal/87880)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 10\
**Last updated:** [November 19, 2024, 8:06am UTC](https://discourse.julialang.org/t/how-to-create-a-union-value-literal/87880 "2024-11-19T08:06:01Z")

</div>

I’d like to initialize an array of type Array{Union{Missing,Float64},2} with a Float64 value. What’s the most succinct way? If you were initializing an Array{Float32,2} with 3.14, you would be doing a = fill(Float32(3.…

---

## [Detecting the type of user input](https://discourse.julialang.org/t/detecting-the-type-of-user-input/122803)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 3\
**Last updated:** [November 19, 2024, 7:16am UTC](https://discourse.julialang.org/t/detecting-the-type-of-user-input/122803 "2024-11-19T07:16:07Z")

</div>

Hello, How to identify the input type? For example, I want to get an input from the user with the readline() command. How can I tell if this input is a number or a string? Thank you.

---

## [Unable to install Mamba](https://discourse.julialang.org/t/unable-to-install-mamba/118612)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 5\
**Last updated:** [November 18, 2024, 5:29pm UTC](https://discourse.julialang.org/t/unable-to-install-mamba/118612 "2024-11-18T17:29:39Z")

</div>

I get following unsatisfiable requirement error when installing mamba ERROR: Unsatisfiable requirements detected for package Mamba \[5424a776\]: Mamba \[5424a776\] log: ├─possible versions are: 0.12.0-0.12.5 or uninstalle…

---

## [Presence of println is affecting function behavior](https://discourse.julialang.org/t/presence-of-println-is-affecting-function-behavior/122694)

<div class="topic-metadata">

**Author:** [@dcgentile](https://discourse.julialang.org/u/dcgentile)\
**Replies:** 10\
**Last updated:** [November 18, 2024, 2:04pm UTC](https://discourse.julialang.org/t/presence-of-println-is-affecting-function-behavior/122694 "2024-11-18T14:04:08Z")

</div>

Hi all — Firstly, hope I’m posting this in the right place, I’m not much of a Discourse user, so if I’m not adhering to the community guidlines, please let me know and I’ll take this elsewhere. Now for the meat of the ma…

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

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