# New to Julia

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

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

**Page:** 29

---

## [Issue in collision count for a ball in 2d space using agent.jl](https://discourse.julialang.org/t/issue-in-collision-count-for-a-ball-in-2d-space-using-agent-jl/122488)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 3\
**Last updated:** [November 18, 2024, 11:09am UTC](https://discourse.julialang.org/t/issue-in-collision-count-for-a-ball-in-2d-space-using-agent-jl/122488 "2024-11-18T11:09:36Z")

</div>

Hello everyone, I have made a MWE for collision problem (2d example) in Agent Based model this based on some of my previous questions. Im using interacting\_pairs to find pairs in model and count collision if it finds an…

---

## [Unexpected behavior of global variables depending on function read/write behavior](https://discourse.julialang.org/t/unexpected-behavior-of-global-variables-depending-on-function-read-write-behavior/122624)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 17\
**Last updated:** [November 18, 2024, 10:11am UTC](https://discourse.julialang.org/t/unexpected-behavior-of-global-variables-depending-on-function-read-write-behavior/122624 "2024-11-18T10:11:18Z")

</div>

Hi, I have been experimenting with the behavior of global variables in Julia. I (perhaps incorrectly) believed the behavior was quite similar, if not exactly the same, as in Python. Here’s some test code: global x="x…

---

## [GPU Julia vs GPU Matlab](https://discourse.julialang.org/t/gpu-julia-vs-gpu-matlab/122663)

<div class="topic-metadata">

**Author:** [@Alex90](https://discourse.julialang.org/u/Alex90)\
**Replies:** 61\
**Last updated:** [November 18, 2024, 9:32am UTC](https://discourse.julialang.org/t/gpu-julia-vs-gpu-matlab/122663 "2024-11-18T09:32:18Z")

</div>

Hello, I have tested a simple math example in Julia using GPU computing and GTX 960. The code is as follows: A = CUDA.rand(151,151,151); B = similar(A); C = CUDA.zeros(151,151,151); D = similar(C); E = similar(C); F = …

---

## [Why does Julia use so much memory?](https://discourse.julialang.org/t/why-does-julia-use-so-much-memory/76677)

<div class="topic-metadata">

**Author:** [@rogerkeays](https://discourse.julialang.org/u/rogerkeays)\
**Replies:** 16\
**Last updated:** [November 17, 2024, 11:14pm UTC](https://discourse.julialang.org/t/why-does-julia-use-so-much-memory/76677 "2024-11-17T23:14:51Z")

</div>

Julia seems to have a pretty high memory footprint. For example, compared to Lisp, which has similar features (dynamic types, homoiconic, incremental compling etc), Julia is pretty bad \[1\]. Is it just because Julia is s…

---

## [Is the Main module the only module where a relative path is not required?](https://discourse.julialang.org/t/is-the-main-module-the-only-module-where-a-relative-path-is-not-required/122713)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 1\
**Last updated:** [November 17, 2024, 11:16am UTC](https://discourse.julialang.org/t/is-the-main-module-the-only-module-where-a-relative-path-is-not-required/122713 "2024-11-17T11:16:13Z")

</div>

Just noticed something which I’m slightly confused by and looks a bit inconsistent. If I write a file main.jl containing the following code include("ExampleModule.jl\`) ExampleModule.exampleFunction() why does this wo…

---

## [Terminating a while loop on an empty-line input](https://discourse.julialang.org/t/terminating-a-while-loop-on-an-empty-line-input/122715)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 5\
**Last updated:** [November 17, 2024, 9:39am UTC](https://discourse.julialang.org/t/terminating-a-while-loop-on-an-empty-line-input/122715 "2024-11-17T09:39:37Z")

</div>

Hello, I want this program to take some numbers from the input and print their sum. This happens until the Enter key is pressed: function numbers() flag = 0 sum = 0 while flag != "" print("Enter the…

---

## [Query on date doesn't return what expected](https://discourse.julialang.org/t/query-on-date-doesnt-return-what-expected/122512)

<div class="topic-metadata">

**Author:** [@andreh](https://discourse.julialang.org/u/andreh)\
**Replies:** 25\
**Last updated:** [November 16, 2024, 10:25pm UTC](https://discourse.julialang.org/t/query-on-date-doesnt-return-what-expected/122512 "2024-11-16T22:25:20Z")

</div>

I am using SQLite to perform queries on my Table “Todos” I run on julia the commands: julia\> using SQLite julia\> db = SQLite.DB(“db/dev.sqlite3”) julia\> using DataFrames From my “Todos” table I want to return valu…

---

## [Can't install Polars and DuckDB on windows 11](https://discourse.julialang.org/t/cant-install-polars-and-duckdb-on-windows-11/122688)

<div class="topic-metadata">

**Author:** [@pk1](https://discourse.julialang.org/u/pk1)\
**Replies:** 6\
**Last updated:** [November 16, 2024, 3:56pm UTC](https://discourse.julialang.org/t/cant-install-polars-and-duckdb-on-windows-11/122688 "2024-11-16T15:56:57Z")

</div>

Hello, I am an experienced programmer, and want to try Julia (1.11.1). For evaluation purposes, I wanted to start by installing two tools that I use regularly and know very well. Polars and DuckDB. I found it very diff…

---

## [Is it possible to split a module across multiple files?](https://discourse.julialang.org/t/is-it-possible-to-split-a-module-across-multiple-files/122711)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 5\
**Last updated:** [November 16, 2024, 12:01pm UTC](https://discourse.julialang.org/t/is-it-possible-to-split-a-module-across-multiple-files/122711 "2024-11-16T12:01:54Z")

</div>

Here are two files showing how one might split a module across two files: # ModuleA1.jl module ModuleA function functionA1() println("functionA1") end end # ModuleA2.jl module ModuleA function functionA2() p…

---

## [How to print the names of symbols defined in modules?](https://discourse.julialang.org/t/how-to-print-the-names-of-symbols-defined-in-modules/122714)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 1\
**Last updated:** [November 16, 2024, 11:44am UTC](https://discourse.julialang.org/t/how-to-print-the-names-of-symbols-defined-in-modules/122714 "2024-11-16T11:44:24Z")

</div>

The names of symbols defined in the Main module can be printed using julia\> names(Main) 8-element Vector{Symbol}: :Base :Core :Main :SRC :TopLevelModule :skipInit :updateLoadPath However the same trick cannot be…

---

## [A question about function](https://discourse.julialang.org/t/a-question-about-function/122708)

<div class="topic-metadata">

**Author:** [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)\
**Replies:** 6\
**Last updated:** [November 16, 2024, 10:51am UTC](https://discourse.julialang.org/t/a-question-about-function/122708 "2024-11-16T10:51:51Z")

</div>

Hello, Please consider the following code: function print3lines() inn = open("input.txt", "r") print1(inn) # read and print first line print2(inn) # read and print second line print3(inn) # rea…

---

## [Julia can be dramatically slower than Matlab when solving 2D PDE](https://discourse.julialang.org/t/julia-can-be-dramatically-slower-than-matlab-when-solving-2d-pde/122321)

<div class="topic-metadata">

**Author:** [@Alex90](https://discourse.julialang.org/u/Alex90)\
**Replies:** 42\
**Last updated:** [November 9, 2024, 2:25pm UTC](https://discourse.julialang.org/t/julia-can-be-dramatically-slower-than-matlab-when-solving-2d-pde/122321 "2024-11-09T14:25:33Z")

</div>

Hello, It is said that Julia is very fast in comparison with other high level languages. SInce i do scientific computing, i was interested in this language. So i compared performance of Julia and Matlab when solving two…

---

## [How do I assign and branch?](https://discourse.julialang.org/t/how-do-i-assign-and-branch/122179)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 9\
**Last updated:** [November 15, 2024, 3:00pm UTC](https://discourse.julialang.org/t/how-do-i-assign-and-branch/122179 "2024-11-15T15:00:45Z")

</div>

Here’s some code. tmp = myFunction() if !isnothing(tmp) doSomethingWith(tmp) end Some languages have a convenient way to express this. The disadvantage of what I have done is introduce a new temporary variable tmp,…

---

## [Pkg error messages in Pluto miss the often basic typo / not-loaded suggestions](https://discourse.julialang.org/t/pkg-error-messages-in-pluto-miss-the-often-basic-typo-not-loaded-suggestions/122676)

<div class="topic-metadata">

**Author:** [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Replies:** 7\
**Last updated:** [November 15, 2024, 2:05pm UTC](https://discourse.julialang.org/t/pkg-error-messages-in-pluto-miss-the-often-basic-typo-not-loaded-suggestions/122676 "2024-11-15T14:05:05Z")

</div>

In Pluto, when Using \[pkg\_name\] fails to load a package it gives “Things you could try”. The package \[pkg\_name\].jl could not load because it failed to initialize. That's not nice! Things you could try: Restart the…

---

## ["Names" of anonymous functions in loops](https://discourse.julialang.org/t/names-of-anonymous-functions-in-loops/58724)

<div class="topic-metadata">

**Author:** [@james-p-foster](https://discourse.julialang.org/u/james-p-foster)\
**Replies:** 6\
**Last updated:** [November 14, 2024, 2:40pm UTC](https://discourse.julialang.org/t/names-of-anonymous-functions-in-loops/58724 "2024-11-14T14:40:54Z")

</div>

I’ve recently been messing around with anonymous functions and loops, trying to generate arrays of functions that are “nested”, i.e. a function generated in a given loop iteration uses functions from previous loop iterat…

---

## [Issue with DataFrame Column Type and Recognition in Julia Scripts](https://discourse.julialang.org/t/issue-with-dataframe-column-type-and-recognition-in-julia-scripts/122595)

<div class="topic-metadata">

**Author:** [@Tommi\_P\_Laiho](https://discourse.julialang.org/u/Tommi_P_Laiho)\
**Replies:** 2\
**Last updated:** [November 14, 2024, 12:56am UTC](https://discourse.julialang.org/t/issue-with-dataframe-column-type-and-recognition-in-julia-scripts/122595 "2024-11-14T00:56:47Z")

</div>

Hello Julia Community, I am currently working on a project involving statistical modeling in Julia, where I am facing an issue with reading and processing a DataFrame. My project includes three main scripts: generate\_…

---

## [Using ForwardDiff.gradient for numerical loop with static arrays and complex numbers](https://discourse.julialang.org/t/using-forwarddiff-gradient-for-numerical-loop-with-static-arrays-and-complex-numbers/122557)

<div class="topic-metadata">

**Author:** [@dameka](https://discourse.julialang.org/u/dameka)\
**Replies:** 3\
**Last updated:** [November 13, 2024, 8:04pm UTC](https://discourse.julialang.org/t/using-forwarddiff-gradient-for-numerical-loop-with-static-arrays-and-complex-numbers/122557 "2024-11-13T20:04:05Z")

</div>

I’m having trouble getting ForwardDiff working with a numerical loop that involved complex numbers. Specifically I’m trying to use static arrays for speed (advised on my previous post), but it seems to be butting heads w…

---

## [Datetime operations](https://discourse.julialang.org/t/datetime-operations/122507)

<div class="topic-metadata">

**Author:** [@SergeantMike67](https://discourse.julialang.org/u/SergeantMike67)\
**Replies:** 5\
**Last updated:** [November 12, 2024, 5:56pm UTC](https://discourse.julialang.org/t/datetime-operations/122507 "2024-11-12T17:56:33Z")

</div>

How does one get a datetime column in a Dataframe to be just the time in the format of “HH:MM:SS”. Currently, those with a time entered, reads as 1899-12-30T13:00:00 and I need it to be just 13:00 The reason is that I …

---

## [Understanding why COBYLA doesn't find optimum here](https://discourse.julialang.org/t/understanding-why-cobyla-doesnt-find-optimum-here/122542)

<div class="topic-metadata">

**Author:** [@JADekker](https://discourse.julialang.org/u/JADekker)\
**Replies:** 5\
**Last updated:** [November 12, 2024, 3:27pm UTC](https://discourse.julialang.org/t/understanding-why-cobyla-doesnt-find-optimum-here/122542 "2024-11-12T15:27:56Z")

</div>

Hi, I’m trying to understand why the COBYLA algorithm doesn’t find the optimal value in the following MWE. By contrast, IPNewton does work. Am I violating some COBYLA assumption that I’m forgetting about? For the problem…

---

## [Example of registering a finalizer for unsafe\_wrapped data from ccall](https://discourse.julialang.org/t/example-of-registering-a-finalizer-for-unsafe-wrapped-data-from-ccall/122499)

<div class="topic-metadata">

**Author:** [@gmcardle](https://discourse.julialang.org/u/gmcardle)\
**Replies:** 9\
**Last updated:** [November 12, 2024, 2:49pm UTC](https://discourse.julialang.org/t/example-of-registering-a-finalizer-for-unsafe-wrapped-data-from-ccall/122499 "2024-11-12T14:49:55Z")

</div>

Hi, I’m using ccall on a C library that returns a pointer to some data that was malloced in the library and requires a separate API call to close the resource that the data came from. The dataset could be quite large (a …

---

## [How to unvectorize a vector to use it as an argument of a function](https://discourse.julialang.org/t/how-to-unvectorize-a-vector-to-use-it-as-an-argument-of-a-function/122441)

<div class="topic-metadata">

**Author:** [@Wooheon](https://discourse.julialang.org/u/Wooheon)\
**Replies:** 4\
**Last updated:** [November 12, 2024, 2:05pm UTC](https://discourse.julialang.org/t/how-to-unvectorize-a-vector-to-use-it-as-an-argument-of-a-function/122441 "2024-11-12T14:05:04Z")

</div>

Hello. I am trying to use a vector output of some function as an input of another function. For example, if ϕₛₑᵣᵢₑₛ₄ is a function that has 17 inputs and coef is a vector of 15 elements, I want to write down ϕₛₑᵣᵢₑₛ₄(c…

---

## [Warning secondorder ADtype in optimization.jl](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539)

<div class="topic-metadata">

**Author:** [@JADekker](https://discourse.julialang.org/u/JADekker)\
**Replies:** 3\
**Last updated:** [November 12, 2024, 10:27am UTC](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539 "2024-11-12T10:27:52Z")

</div>

Hi, I’m trying to replicate the example from Optim.jl · Optimization.jl, i.e. I’m running using Optimization, OptimizationOptimJL function RunTest() rosenbrock(x, p) = (p\[1\] - x\[1\])^2 + p\[2\] \* (x\[2\] - x\[1\]^2)^2 …

---

## [How to use the REPL to speed up modular development by dynamically replacing function definitions](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 26\
**Last updated:** [November 12, 2024, 9:22am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326 "2024-11-12T09:22:37Z")

</div>

I have a question about workflows in Julia, or alternatively, some aspects of how the REPL can be used. Allow me to start by describing how I am currently constrained. I recognized that what I am about to describe will…

---

## [How to run a simple agent-based model via abmplot()](https://discourse.julialang.org/t/how-to-run-a-simple-agent-based-model-via-abmplot/122476)

<div class="topic-metadata">

**Author:** [@pogikano](https://discourse.julialang.org/u/pogikano)\
**Replies:** 0\
**Last updated:** [November 11, 2024, 12:24am UTC](https://discourse.julialang.org/t/how-to-run-a-simple-agent-based-model-via-abmplot/122476 "2024-11-11T00:24:25Z")

</div>

This simple model in continuous space starts with one dead (immobile) object and 500 live (moving ) ones. If a live object gets close to a dead one, it dies. The result should be a growing pattern. The control panel show…

---

## [How to simplify complicated expression further?](https://discourse.julialang.org/t/how-to-simplify-complicated-expression-further/122110)

<div class="topic-metadata">

**Author:** [@aligurbu](https://discourse.julialang.org/u/aligurbu)\
**Replies:** 6\
**Last updated:** [November 11, 2024, 5:45pm UTC](https://discourse.julialang.org/t/how-to-simplify-complicated-expression-further/122110 "2024-11-11T17:45:17Z")

</div>

Hello everyone, I am using Pluto and Symbolics.jl for symbolic computations and encountered a challenge in simplifying results. Here’s the code I am working with: solutions = symbolic\_linear\_solve(\[L1 ~ 0, L2 ~ 0, L3 ~…

---

## [The Julia shell doesn't have an environment variable $SHELL?](https://discourse.julialang.org/t/the-julia-shell-doesnt-have-an-environment-variable-shell/122498)

<div class="topic-metadata">

**Author:** [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Replies:** 3\
**Last updated:** [November 11, 2024, 2:57pm UTC](https://discourse.julialang.org/t/the-julia-shell-doesnt-have-an-environment-variable-shell/122498 "2024-11-11T14:57:20Z")

</div>

What is the Julia shell? It doesn’t appear to have an environment variable $SHELL. Normally most (Linux) shells define this environment variable to tell the user that the current shell is a Bash shell or /bin/sh shell, …

---

## [MethodError: no method matching getindex](https://discourse.julialang.org/t/methoderror-no-method-matching-getindex/22496)

<div class="topic-metadata">

**Author:** [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Replies:** 10\
**Last updated:** [November 11, 2024, 2:34pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-getindex/22496 "2024-11-11T14:34:21Z")

</div>

Dear All, I’m trying to call a function(.jl) in a folder. terminal reported a bug: "MethodError: no method matching getindex" Attached text you find the test code: function testc(Nx,Ny,c0) NxNy = Nx\*Ny ccc=zeros(Nx…

---

## [Creative Coding in Julia (packages for audio and graphics processing)](https://discourse.julialang.org/t/creative-coding-in-julia-packages-for-audio-and-graphics-processing/72005)

<div class="topic-metadata">

**Author:** [@woodwindblues](https://discourse.julialang.org/u/woodwindblues)\
**Replies:** 11\
**Last updated:** [November 10, 2024, 1:07pm UTC](https://discourse.julialang.org/t/creative-coding-in-julia-packages-for-audio-and-graphics-processing/72005 "2024-11-10T13:07:46Z")

</div>

Hello, I am coming from a musician backround and am lookng for a programming language to code interactive audio-visual installations. I have some experience in coding with Java (a year of computer engineering many years…

---

## [What is causing this undefined variable Error message](https://discourse.julialang.org/t/what-is-causing-this-undefined-variable-error-message/122429)

<div class="topic-metadata">

**Author:** [@Anika\_Tarannum](https://discourse.julialang.org/u/Anika_Tarannum)\
**Replies:** 2\
**Last updated:** [November 8, 2024, 7:40pm UTC](https://discourse.julialang.org/t/what-is-causing-this-undefined-variable-error-message/122429 "2024-11-08T19:40:01Z")

</div>

Define parameters operating\_cost = \[4000, 4200, 4800, 5800, 7200, 9000\] salvage\_value = \[10500, 7300, 5100, 3600, 2500, 1600\] replacement\_cost = 15000 maintenance\_cost = 3500 years = 5 Initialize DP table C\[t\]\[a\] wi…

---

## [Use of Interpolations with ModelingToolkit](https://discourse.julialang.org/t/use-of-interpolations-with-modelingtoolkit/121382)

<div class="topic-metadata">

**Author:** [@Ricardo\_Borges](https://discourse.julialang.org/u/Ricardo_Borges)\
**Replies:** 14\
**Last updated:** [November 8, 2024, 7:04pm UTC](https://discourse.julialang.org/t/use-of-interpolations-with-modelingtoolkit/121382 "2024-11-08T19:04:10Z")

</div>

Hi, I’m using ModelingToolkit to model a battery cell using the Equivalent Circuit Model (ECM) approach. For that, I will be using 2-D lookup tables for the values of Vocv, resistnaces and time constants/capacitances, w…

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

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