# General Usage

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

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

**Page:** 550

---

## [( (x,y) -\> x+y ).( \[ (1,2), (3,4) \] )](https://discourse.julialang.org/t/x-y-x-y-1-2-3-4/67846)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 8\
**Last updated:** [September 8, 2021, 5:43am UTC](https://discourse.julialang.org/t/x-y-x-y-1-2-3-4/67846 "2021-09-08T05:43:14Z")

</div>

( (x,y) -\> x+y ).( \[ (1,2), (3,4) \] ) gives an error. Is it possible to apply a multi-variable anonymous function to a vector of tuples like this ?

---

## [Help: confused by behaviour of \`hasmethod\`](https://discourse.julialang.org/t/help-confused-by-behaviour-of-hasmethod/67818)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 1\
**Last updated:** [September 7, 2021, 2:41pm UTC](https://discourse.julialang.org/t/help-confused-by-behaviour-of-hasmethod/67818 "2021-09-07T14:41:41Z")

</div>

Can anybody please explain why in the following snippet hasmethod returns false? Thanks julia\> hasmethod(parse, Tuple{Int,String}) false julia\> parse(Int, "200") 200

---

## [Suggestion: Enhanced feedback when restarting Julia is required](https://discourse.julialang.org/t/suggestion-enhanced-feedback-when-restarting-julia-is-required/67810)

<div class="topic-metadata">

**Author:** [@martin.demare](https://discourse.julialang.org/u/martin.demare)\
**Replies:** 0\
**Last updated:** [September 7, 2021, 12:17pm UTC](https://discourse.julialang.org/t/suggestion-enhanced-feedback-when-restarting-julia-is-required/67810 "2021-09-07T12:17:51Z")

</div>

Hi, When a package is added which alters the versions of already loaded packages, Julia needs to be restarted to access the correct versions. The feedback to the user is however somewhat timid, and as a new user I faile…

---

## [How to prevent global variable or array in module?](https://discourse.julialang.org/t/how-to-prevent-global-variable-or-array-in-module/65785)

<div class="topic-metadata">

**Author:** [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Replies:** 8\
**Last updated:** [September 7, 2021, 9:11am UTC](https://discourse.julialang.org/t/how-to-prevent-global-variable-or-array-in-module/65785 "2021-09-07T09:11:53Z")

</div>

I am coming from Fortran to Julia. I know in Julia want to prevent using global variables. But the thing is, how to prevent using global variables in a module? For example, in the following module, module Mod global A…

---

## [Memcpy in julia](https://discourse.julialang.org/t/memcpy-in-julia/67791)

<div class="topic-metadata">

**Author:** [@Beh123](https://discourse.julialang.org/u/Beh123)\
**Replies:** 5\
**Last updated:** [September 7, 2021, 8:45am UTC](https://discourse.julialang.org/t/memcpy-in-julia/67791 "2021-09-07T08:45:57Z")

</div>

Hi everyone I have a vector which contains 5 uint8 elements. How do I copy them to two int32 variables ? we can do it with memcpy in c. Is there similar command in julia? x=\[0x3 0x00 0x11 0x00 0x80\] m= convert(Int32…

---

## [Overloading isunit from Nemo ring/field](https://discourse.julialang.org/t/overloading-isunit-from-nemo-ring-field/67777)

<div class="topic-metadata">

**Author:** [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Replies:** 6\
**Last updated:** [September 7, 2021, 6:42am UTC](https://discourse.julialang.org/t/overloading-isunit-from-nemo-ring-field/67777 "2021-09-07T06:42:12Z")

</div>

Hi everybody ! My first attempt was quite successful ! I wanted to check experimentally that Z/nZ is a field if and only if n is a prime number. This is easy to prove but it was just an opportunity to use the Nemo resi…

---

## [How to run a file/script in the Linux terminal (Ubuntu) assigning multi-threading?](https://discourse.julialang.org/t/how-to-run-a-file-script-in-the-linux-terminal-ubuntu-assigning-multi-threading/67784)

<div class="topic-metadata">

**Author:** [@bojusemo](https://discourse.julialang.org/u/bojusemo)\
**Replies:** 3\
**Last updated:** [September 7, 2021, 6:05am UTC](https://discourse.julialang.org/t/how-to-run-a-file-script-in-the-linux-terminal-ubuntu-assigning-multi-threading/67784 "2021-09-07T06:05:11Z")

</div>

Hi Folks, Could anybody guide me, please? How to run a file/script in the Linux terminal (Ubuntu) assigning multi-threading? If in the first line of the script I use #!/path/of/bin/julia it works without multi-threadin…

---

## [How to pass a big chunk of data from C++ to a Julia script without making a copy?](https://discourse.julialang.org/t/how-to-pass-a-big-chunk-of-data-from-c-to-a-julia-script-without-making-a-copy/67779)

<div class="topic-metadata">

**Author:** [@solaris](https://discourse.julialang.org/u/solaris)\
**Replies:** 2\
**Last updated:** [September 7, 2021, 2:07am UTC](https://discourse.julialang.org/t/how-to-pass-a-big-chunk-of-data-from-c-to-a-julia-script-without-making-a-copy/67779 "2021-09-07T02:07:35Z")

</div>

Say I have a meg of data of some structure. For example, struct NodeData { float position\[3\]; float orientation\[4\]; unsigned int connectedNodeIndices\[5\]; }; I want to pass this data from C++ to a Julia scr…

---

## [Nemo - Error in overloading operator '=='](https://discourse.julialang.org/t/nemo-error-in-overloading-operator/67773)

<div class="topic-metadata">

**Author:** [@Gilles\_Dubois](https://discourse.julialang.org/u/Gilles_Dubois)\
**Replies:** 2\
**Last updated:** [September 6, 2021, 9:17pm UTC](https://discourse.julialang.org/t/nemo-error-in-overloading-operator/67773 "2021-09-06T21:17:13Z")

</div>

Hello everybody ! I want to construct product rings (fields) of modular integers. For example Z/5ZxZ/7Z I began like this : #http://nemocas.github.io/Nemo.jl/v0.6/types/#the-abstract-type-hierarchy-in-nemo using Nemo …

---

## [Why does 16//1 and 16.0 not equal 16 in for loop?](https://discourse.julialang.org/t/why-does-16-1-and-16-0-not-equal-16-in-for-loop/67748)

<div class="topic-metadata">

**Author:** [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Replies:** 8\
**Last updated:** [September 6, 2021, 8:42pm UTC](https://discourse.julialang.org/t/why-does-16-1-and-16-0-not-equal-16-in-for-loop/67748 "2021-09-06T20:42:16Z")

</div>

I am getting some behavior I can not explain. The context is that a chamber gets 9/16’ths of its content emptied, initially air. Then the 9/16ths that were removed are replaced with some pure gas. This process is repeted…

---

## [LinearAlgebra: rank](https://discourse.julialang.org/t/linearalgebra-rank/67763)

<div class="topic-metadata">

**Author:** [@unhandyandy](https://discourse.julialang.org/u/unhandyandy)\
**Replies:** 8\
**Last updated:** [September 6, 2021, 7:56pm UTC](https://discourse.julialang.org/t/linearalgebra-rank/67763 "2021-09-06T19:56:07Z")

</div>

What exactly does the rank function compute? I thought it would give the number of llinearly independent rows in a matrix, but evidently not. Here cov is a 138x138 matrix. 1|julia\> rank(cov\[1:20,1:20\]) 20 1|julia\> ra…

---

## [How to search the manual more efficiently](https://discourse.julialang.org/t/how-to-search-the-manual-more-efficiently/19314)

<div class="topic-metadata">

**Author:** [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Replies:** 12\
**Last updated:** [September 6, 2021, 7:48pm UTC](https://discourse.julialang.org/t/how-to-search-the-manual-more-efficiently/19314 "2021-09-06T19:48:46Z")

</div>

I find myself using Julia’s online manual a lot, and thought I’d share this simple trick on how to do that more efficiently if you’re using Chrome as a browser: Enter chrome://settings/ in Chrome’s URL bar. Scroll down…

---

## [Efficient Way of Installing Packages](https://discourse.julialang.org/t/efficient-way-of-installing-packages/67770)

<div class="topic-metadata">

**Author:** [@mo\_re](https://discourse.julialang.org/u/mo_re)\
**Replies:** 4\
**Last updated:** [September 6, 2021, 7:10pm UTC](https://discourse.julialang.org/t/efficient-way-of-installing-packages/67770 "2021-09-06T19:10:24Z")

</div>

Hey everyone, while learning R I came across a forum post that was very helpful for checking and installing what packages were missing for a user. The R code went like this: packages \<- c("package names"...) # Install…

---

## [Anonymous function in count()](https://discourse.julialang.org/t/anonymous-function-in-count/67761)

<div class="topic-metadata">

**Author:** [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Replies:** 9\
**Last updated:** [September 6, 2021, 7:02pm UTC](https://discourse.julialang.org/t/anonymous-function-in-count/67761 "2021-09-06T19:02:51Z")

</div>

The slowdown of using something like count(z-\>(edges\[1\]\<z\<=edges\[2\]),x) is substantial, and can be avoided by a wrapping another function (see below). Is this the same as 10x slowdown when passing function as argument? …

---

## [@threads for loop to find maximum of function](https://discourse.julialang.org/t/threads-for-loop-to-find-maximum-of-function/53263)

<div class="topic-metadata">

**Author:** [@MFairley](https://discourse.julialang.org/u/MFairley)\
**Replies:** 19\
**Last updated:** [September 6, 2021, 4:14pm UTC](https://discourse.julialang.org/t/threads-for-loop-to-find-maximum-of-function/53263 "2021-09-06T16:14:20Z")

</div>

The following code causes a type instability. Is there a better way to write this code? Perhaps using Threads.Atomic? max\_obj = -Inf64 xs = 0.0 Threads.@threads for i = 1:100 obj, x = f(i) if obj \>= max\_obj …

---

## [CairoMakie wont display plots (running from terminal)](https://discourse.julialang.org/t/cairomakie-wont-display-plots-running-from-terminal/67755)

<div class="topic-metadata">

**Author:** [@RTbecard](https://discourse.julialang.org/u/RTbecard)\
**Replies:** 2\
**Last updated:** [September 6, 2021, 3:41pm UTC](https://discourse.julialang.org/t/cairomakie-wont-display-plots-running-from-terminal/67755 "2021-09-06T15:41:03Z")

</div>

Not sure why… but I can’t get Makie plots to display. I’m running julia 1.6.1 from my terminal on PopOS 21.04. The docs tell me that this is a backend build issue… but when I ran pkg\> test CairoMakie, all tests passed…

---

## [Issues reading CSV file with array elements](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747)

<div class="topic-metadata">

**Author:** [@Cevheriferd](https://discourse.julialang.org/u/Cevheriferd)\
**Replies:** 4\
**Last updated:** [September 6, 2021, 1:55pm UTC](https://discourse.julialang.org/t/issues-reading-csv-file-with-array-elements/67747 "2021-09-06T13:55:47Z")

</div>

The problem is as follows: I have a dataframe with a column that has Vector{Float64} elements. When I store the dataframe in a CSV file and then retrieve it, the type of the column changed from Vector{Float64} to String…

---

## [Assign values to a subarray and it take a long time and large allocation](https://discourse.julialang.org/t/assign-values-to-a-subarray-and-it-take-a-long-time-and-large-allocation/67711)

<div class="topic-metadata">

**Author:** [@disadone](https://discourse.julialang.org/u/disadone)\
**Replies:** 4\
**Last updated:** [September 6, 2021, 1:11pm UTC](https://discourse.julialang.org/t/assign-values-to-a-subarray-and-it-take-a-long-time-and-large-allocation/67711 "2021-09-06T13:11:42Z")

</div>

I have functions such as function max\_(v::Matrix{Float64}) m,idx=findmax(v,dims=2) Dt=vec(getindex.(idx,2)) return m,Dt end function max\_!(Vs::AbstractVector{Float64},Ds::AbstractVector{Float64},v::Matrix{F…

---

## [How to programmatically check if an allocation is possible](https://discourse.julialang.org/t/how-to-programmatically-check-if-an-allocation-is-possible/67697)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 10\
**Last updated:** [September 6, 2021, 12:44pm UTC](https://discourse.julialang.org/t/how-to-programmatically-check-if-an-allocation-is-possible/67697 "2021-09-06T12:44:09Z")

</div>

Hi, I have some code that can do some performance optimizations provided that an allocation of some matrix NxN is possible. If N is too large, I get an out of memory error. In this case I can use an alternative algorithm…

---

## [Multithreading, preallocation of objects, threadid() and task migration](https://discourse.julialang.org/t/multithreading-preallocation-of-objects-threadid-and-task-migration/67640)

<div class="topic-metadata">

**Author:** [@Bruno\_Amorim](https://discourse.julialang.org/u/Bruno_Amorim)\
**Replies:** 18\
**Last updated:** [September 6, 2021, 10:17am UTC](https://discourse.julialang.org/t/multithreading-preallocation-of-objects-threadid-and-task-migration/67640 "2021-09-06T10:17:51Z")

</div>

Suppose we have a function, do\_stuff!(mat, x), that mutates a previously allocated matrix mat and returns some value. We want to run the function for several values of x using multithreading. In order to avoid data races…

---

## [Passing \`val\` to notify on Condition](https://discourse.julialang.org/t/passing-val-to-notify-on-condition/67643)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 2\
**Last updated:** [September 6, 2021, 9:09am UTC](https://discourse.julialang.org/t/passing-val-to-notify-on-condition/67643 "2021-09-06T09:09:54Z")

</div>

The manual (Tasks · The Julia Language) says that notify can pass val to its waiting conditions. How can I obtain val from the woken up conditions?

---

## [Reordering NamedTuples](https://discourse.julialang.org/t/reordering-namedtuples/67600)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 11\
**Last updated:** [September 6, 2021, 8:04am UTC](https://discourse.julialang.org/t/reordering-namedtuples/67600 "2021-09-06T08:04:20Z")

</div>

Dear All, I want to ask, if anyone knows about fast (ideally typed stable) method to reorder named tuples. A MWE would look like (a = 1, b = 2, c = 3) julia\> y = (c = 1, b = 2, a = 1) (c = 1, b = 2, a = 1) julia\> ma…

---

## [\_\_init\_\_() doesn't allow access to pycall functions](https://discourse.julialang.org/t/init-doesnt-allow-access-to-pycall-functions/67402)

<div class="topic-metadata">

**Author:** [@mdsa3d](https://discourse.julialang.org/u/mdsa3d)\
**Replies:** 2\
**Last updated:** [September 6, 2021, 6:12am UTC](https://discourse.julialang.org/t/init-doesnt-allow-access-to-pycall-functions/67402 "2021-09-06T06:12:21Z")

</div>

I am running a test on the implementation of init() for pycall and I built an example using the scipy.interpolate.Rbf and PyCall documentation. Code: module test\_rbf using PyCall function \_\_init\_\_() py""" imp…

---

## [How to return the index of element in Array in Integer not CartesianIndex?](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 2\
**Last updated:** [September 6, 2021, 5:08am UTC](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728 "2021-09-06T05:08:23Z")

</div>

I have the following array (here is vector), and I want to return the index of “8” element, which should be 4 as integer not CartesianIndex. Any solution? julia\> s=\[5 6 7 8\] 1×4 Matrix{Int64}: 5 6 7 8 julia\> findal…

---

## [Improving metropolis-hastings code](https://discourse.julialang.org/t/improving-metropolis-hastings-code/67412)

<div class="topic-metadata">

**Author:** [@marouane](https://discourse.julialang.org/u/marouane)\
**Replies:** 21\
**Last updated:** [September 6, 2021, 3:22am UTC](https://discourse.julialang.org/t/improving-metropolis-hastings-code/67412 "2021-09-06T03:22:16Z")

</div>

Recently i’m looking for different ways to make the metropolis-hastings algorithm better specially when it comes to rate of the accepted values and the performance, specially if i’m writing this code manually without any…

---

## [Avoid negative Values](https://discourse.julialang.org/t/avoid-negative-values/67656)

<div class="topic-metadata">

**Author:** [@DerOzean](https://discourse.julialang.org/u/DerOzean)\
**Replies:** 13\
**Last updated:** [September 5, 2021, 3:47pm UTC](https://discourse.julialang.org/t/avoid-negative-values/67656 "2021-09-05T15:47:32Z")

</div>

Hi, I’m trying to solve a food-web with many interacting diffeq. Because animals and plants can’t have negative population sizes it would be great to restrict the solution to only positive values. Additionally some of t…

---

## [How to initialize a GeometryBasics.Point{2, Float32} that contains no point?](https://discourse.julialang.org/t/how-to-initialize-a-geometrybasics-point-2-float32-that-contains-no-point/67701)

<div class="topic-metadata">

**Author:** [@GoH](https://discourse.julialang.org/u/GoH)\
**Replies:** 7\
**Last updated:** [September 5, 2021, 11:45am UTC](https://discourse.julialang.org/t/how-to-initialize-a-geometrybasics-point-2-float32-that-contains-no-point/67701 "2021-09-05T11:45:43Z")

</div>

I am trying to initialize an empty GeometryBasics.Point{2, Float32}, could anyone help?

---

## [Gantt chart for profiling multi threaded code?](https://discourse.julialang.org/t/gantt-chart-for-profiling-multi-threaded-code/67672)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 4\
**Last updated:** [September 5, 2021, 7:07am UTC](https://discourse.julialang.org/t/gantt-chart-for-profiling-multi-threaded-code/67672 "2021-09-05T07:07:42Z")

</div>

Investigating the bottleneck in a parallel program preventing it from scaling linearly like its C++ counterpart. The program includes I/O and uses CodeZlib (which has ccall). Trying to see how threads are spending time. …

---

## [Preserving HTML when processing Markdown](https://discourse.julialang.org/t/preserving-html-when-processing-markdown/12380)

<div class="topic-metadata">

**Author:** [@miles](https://discourse.julialang.org/u/miles)\
**Replies:** 0\
**Last updated:** [July 14, 2018, 7:47pm UTC](https://discourse.julialang.org/t/preserving-html-when-processing-markdown/12380 "2018-07-14T19:47:44Z")

</div>

Hi, I am using the built in Julia Markdown parser like this: html = Base.Markdown.html(Markdown.parse\_file(ifname)) Here “ifname” is a file containing Markdown text source. The result, “html” is a string that contains …

---

## [Using NLsolve to find multiple roots](https://discourse.julialang.org/t/using-nlsolve-to-find-multiple-roots/67637)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 8\
**Last updated:** [September 5, 2021, 1:55am UTC](https://discourse.julialang.org/t/using-nlsolve-to-find-multiple-roots/67637 "2021-09-05T01:55:29Z")

</div>

I have two non-linear equations for which I want to find all roots. Using nlsolve only returns one root. How can I configure it to return all roots, say in some range of parameters?

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

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