# General Usage

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

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

**Page:** 818

---

## [Question on semantics of loops, maps, and broadcast](https://discourse.julialang.org/t/question-on-semantics-of-loops-maps-and-broadcast/30706)

<div class="topic-metadata">

**Author:** [@klaff](https://discourse.julialang.org/u/klaff)\
**Replies:** 6\
**Last updated:** [November 5, 2019, 3:10am UTC](https://discourse.julialang.org/t/question-on-semantics-of-loops-maps-and-broadcast/30706 "2019-11-05T03:10:00Z")

</div>

I’ve been playing with writing things in different forms, for example the following: function f\_by\_loop!(data,x) @inbounds for i in eachindex(data) data\[i\] = min(x,data\[i\]) end end vs data .= min.(x,dat…

---

## [Clipper.jl - execute\_pt() method for ClipperOffset](https://discourse.julialang.org/t/clipper-jl-execute-pt-method-for-clipperoffset/30711)

<div class="topic-metadata">

**Author:** [@Josiah\_Slack](https://discourse.julialang.org/u/Josiah_Slack)\
**Replies:** 0\
**Last updated:** [November 4, 2019, 7:16pm UTC](https://discourse.julialang.org/t/clipper-jl-execute-pt-method-for-clipperoffset/30711 "2019-11-04T19:16:52Z")

</div>

I’ve got a situation where I’d like to construct a PolyNode from a ClipperOffset object. Is there an execute\_pt() method waiting in the wings? Alternatively, is there a reasonable way of constructing a PolyNode from the …

---

## [Result changes depending on whether matrix is sparse or not](https://discourse.julialang.org/t/result-changes-depending-on-whether-matrix-is-sparse-or-not/30669)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 16\
**Last updated:** [November 4, 2019, 4:51pm UTC](https://discourse.julialang.org/t/result-changes-depending-on-whether-matrix-is-sparse-or-not/30669 "2019-11-04T16:51:51Z")

</div>

I get this weird bug (I assume) but I cannot reproduce it with another matrix. So this is the setup: A = sparse(\[1,2,1,3,3,4,5\], \[3,3,4,4,5,6,6,\], \[1,1,1,1,1,1,1\], 6, 6 ) A = convert(SparseMatrixCSC{Float64,Int64},A) …

---

## [GLM.jl Is posulbie to use lm() for two vectors without DataFrames?](https://discourse.julialang.org/t/glm-jl-is-posulbie-to-use-lm-for-two-vectors-without-dataframes/30703)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 2\
**Last updated:** [November 4, 2019, 4:35pm UTC](https://discourse.julialang.org/t/glm-jl-is-posulbie-to-use-lm-for-two-vectors-without-dataframes/30703 "2019-11-04T16:35:22Z")

</div>

Is posulbie to use lm() for two vectors" julia\>using GLM x=rand(10); julia\> y=rand(10); julia\> lm(x,y) ERROR: MethodError: no method matching... Just I cant to use DataFrames. Thanks, Paul

---

## [What to do when Julia crashes](https://discourse.julialang.org/t/what-to-do-when-julia-crashes/30690)

<div class="topic-metadata">

**Author:** [@PGS62](https://discourse.julialang.org/u/PGS62)\
**Replies:** 7\
**Last updated:** [November 4, 2019, 4:17pm UTC](https://discourse.julialang.org/t/what-to-do-when-julia-crashes/30690 "2019-11-04T16:17:16Z")

</div>

I’m working on porting an in-house library from R to Julia. On the plus side I’m seeing greatly improved performance - in the best case a 1,000 times speed up for code that performs an optimisation using LNopt versus R …

---

## [ReverseDiff.GradientTapes for functions of the form x -\> f(x, y) when gradient is to be calculated wrt x only?](https://discourse.julialang.org/t/reversediff-gradienttapes-for-functions-of-the-form-x-f-x-y-when-gradient-is-to-be-calculated-wrt-x-only/30668)

<div class="topic-metadata">

**Author:** [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Replies:** 2\
**Last updated:** [November 4, 2019, 2:20pm UTC](https://discourse.julialang.org/t/reversediff-gradienttapes-for-functions-of-the-form-x-f-x-y-when-gradient-is-to-be-calculated-wrt-x-only/30668 "2019-11-04T14:20:20Z")

</div>

Hello, I typically differentiate log-likelihood functions of the forms x → f(x, data) wrt x, where x is a multi-dimensional input, data is some fixed dataframe, f is a scalar-valued function. To do so, I typically use e…

---

## ["q" letter missing in unicode autocompletion mode](https://discourse.julialang.org/t/q-letter-missing-in-unicode-autocompletion-mode/30697)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [November 4, 2019, 2:25pm UTC](https://discourse.julialang.org/t/q-letter-missing-in-unicode-autocompletion-mode/30697 "2019-11-04T14:25:15Z")

</div>

Is there a reason q and Q are missing ?

---

## [Colored legend with Makie](https://discourse.julialang.org/t/colored-legend-with-makie/30691)

<div class="topic-metadata">

**Author:** [@cserteGT3](https://discourse.julialang.org/u/cserteGT3)\
**Replies:** 2\
**Last updated:** [November 4, 2019, 2:07pm UTC](https://discourse.julialang.org/t/colored-legend-with-makie/30691 "2019-11-04T14:07:49Z")

</div>

A have a colored scatterplot (made with Makie) and would like to make a legend that explains what the colors mean. How should I modify the following example to achieve this? Tried the kwargs suggested by the docs of lege…

---

## [Call C++ library from Julia with the Cxx package?](https://discourse.julialang.org/t/call-c-library-from-julia-with-the-cxx-package/30661)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 5\
**Last updated:** [November 4, 2019, 8:59am UTC](https://discourse.julialang.org/t/call-c-library-from-julia-with-the-cxx-package/30661 "2019-11-04T08:59:55Z")

</div>

Hi, I was wondering, does anyone have similar experiences as calling C++ library from Julia? I have only found one reference Calling C++ library (CGAL) from Julia. More specifically, the library I’m interested in is http…

---

## [How to update packages under development to the latest commit?](https://discourse.julialang.org/t/how-to-update-packages-under-development-to-the-latest-commit/30607)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 3\
**Last updated:** [November 4, 2019, 4:30am UTC](https://discourse.julialang.org/t/how-to-update-packages-under-development-to-the-latest-commit/30607 "2019-11-04T04:30:58Z")

</div>

how to update packages under development to the latest commit in Julia REPL without using git? I was expecting that the '\] update\` will work but it did not?!

---

## [Project with scripts (bin/)](https://discourse.julialang.org/t/project-with-scripts-bin/24360)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 5\
**Last updated:** [November 4, 2019, 12:27am UTC](https://discourse.julialang.org/t/project-with-scripts-bin/24360 "2019-11-04T00:27:11Z")

</div>

At some point in the bag old (pre-Pkg3) days, when discussing what Pkg3 might be able to, I asked if it would be possible to create a package in a way that would automatically “install” scripts (eg point the system $PATH …

---

## [Add println in Julia code and reload, can this be done? (likely bug in WeakKeyDict)](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564)

<div class="topic-metadata">

**Author:** [@swissr](https://discourse.julialang.org/u/swissr)\
**Replies:** 2\
**Last updated:** [October 31, 2019, 10:32pm UTC](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564 "2019-10-31T22:32:50Z")

</div>

Context: The following command causes a dead-lock in 1.4.0-DEV.407 (2019-10-31) and likely also in 1.3. It works fine in 1.03 and 1.2. x = WeakKeyDict(:a1 =\> 4) push!(x, :a2 =\> 2) # WARNING: deadlock here I thought I c…

---

## [@cxx in julia](https://discourse.julialang.org/t/cxx-in-julia/30660)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 2\
**Last updated:** [November 3, 2019, 9:18pm UTC](https://discourse.julialang.org/t/cxx-in-julia/30660 "2019-11-03T21:18:41Z")

</div>

julia\> cxx""" #include \<iostream\> class Hello { public: void hello\_world(const char \*now) { std::string sn…

---

## [Call c++ library from julia](https://discourse.julialang.org/t/call-c-library-from-julia/30653)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 6\
**Last updated:** [November 3, 2019, 5:16pm UTC](https://discourse.julialang.org/t/call-c-library-from-julia/30653 "2019-11-03T17:16:44Z")

</div>

I need to call a C++ library from Julia. I was thinking to try either Cxx package or CxxWrap package. For Cxx, when I was trying to install this Cxx package to my Julia, get the following error message: (v1.1) pkg\> add…

---

## [How to get a included .jl files path list in REPL](https://discourse.julialang.org/t/how-to-get-a-included-jl-files-path-list-in-repl/30647)

<div class="topic-metadata">

**Author:** [@AtsushiSakai](https://discourse.julialang.org/u/AtsushiSakai)\
**Replies:** 1\
**Last updated:** [November 3, 2019, 1:12pm UTC](https://discourse.julialang.org/t/how-to-get-a-included-jl-files-path-list-in-repl/30647 "2019-11-03T13:12:02Z")

</div>

Is there a way to get a path list of all included .jl files in REPL?

---

## [Indexing 1-Dimentional Arrays](https://discourse.julialang.org/t/indexing-1-dimentional-arrays/30615)

<div class="topic-metadata">

**Author:** [@4aHxKzD](https://discourse.julialang.org/u/4aHxKzD)\
**Replies:** 4\
**Last updated:** [November 3, 2019, 8:18am UTC](https://discourse.julialang.org/t/indexing-1-dimentional-arrays/30615 "2019-11-03T08:18:51Z")

</div>

Hello. I was reading Julia’s manual (Section: Noteworthy differences) and came across this quote. Julia has true one-dimensional arrays. Column vectors are of size N , not Nx1 . For example, rand(N) makes a 1-dimens…

---

## [Transpose of a sparse matrix is not a sparse matrix?](https://discourse.julialang.org/t/transpose-of-a-sparse-matrix-is-not-a-sparse-matrix/30638)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 1\
**Last updated:** [November 3, 2019, 1:09am UTC](https://discourse.julialang.org/t/transpose-of-a-sparse-matrix-is-not-a-sparse-matrix/30638 "2019-11-03T01:09:10Z")

</div>

I don’t understand what is happening here: julia\> transpose(sparse(Matrix(1I, 5, 5))) 5×5 Transpose{Int64,SparseMatrixCSC{Int64,Int64}}: 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 What i…

---

## [Type stability: ProfileView and @code\_warntype don't agree](https://discourse.julialang.org/t/type-stability-profileview-and-code-warntype-dont-agree/30619)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 4\
**Last updated:** [November 2, 2019, 11:15pm UTC](https://discourse.julialang.org/t/type-stability-profileview-and-code-warntype-dont-agree/30619 "2019-11-02T23:15:56Z")

</div>

I have some code that I feel should run faster (see below). So I ran it with @profile and looked at the results with ProfileView.view() and as expected a lot of red showed up (i.e. runtime method lookup), the correspind…

---

## [Writable global const arrays](https://discourse.julialang.org/t/writable-global-const-arrays/30635)

<div class="topic-metadata">

**Author:** [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 8:49pm UTC](https://discourse.julialang.org/t/writable-global-const-arrays/30635 "2019-11-02T20:49:32Z")

</div>

I tried to implement the xoshiro RNG for Base julia (cf https://github.com/JuliaLang/julia/issues/27614). So, for this to work properly, I thought about using something like const global\_xorostate = zeros(UInt64, Threa…

---

## [Loading time for 2 packages \>\> sum of individual loading time](https://discourse.julialang.org/t/loading-time-for-2-packages-sum-of-individual-loading-time/30630)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 3\
**Last updated:** [November 2, 2019, 5:47pm UTC](https://discourse.julialang.org/t/loading-time-for-2-packages-sum-of-individual-loading-time/30630 "2019-11-02T17:47:25Z")

</div>

Reproducibly I get the following issue: loading just CategoricalArrays takes \< 1s; loading just Requires \< 1s loading both in the same session takes 8s. (see screenshot below FWIW) I tried this with and without Rev…

---

## [Problem with pop!](https://discourse.julialang.org/t/problem-with-pop/30627)

<div class="topic-metadata">

**Author:** [@Caterina\_Cerutti](https://discourse.julialang.org/u/Caterina_Cerutti)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 5:01pm UTC](https://discourse.julialang.org/t/problem-with-pop/30627 "2019-11-02T17:01:12Z")

</div>

I don’t understand why it doesn’t recognise the function pop!. Can someone help me please?

---

## [Any methods to let a custom function automatically run by GC after each garbage collection operation?](https://discourse.julialang.org/t/any-methods-to-let-a-custom-function-automatically-run-by-gc-after-each-garbage-collection-operation/30423)

<div class="topic-metadata">

**Author:** [@runapp](https://discourse.julialang.org/u/runapp)\
**Replies:** 3\
**Last updated:** [November 2, 2019, 1:37pm UTC](https://discourse.julialang.org/t/any-methods-to-let-a-custom-function-automatically-run-by-gc-after-each-garbage-collection-operation/30423 "2019-11-02T13:37:18Z")

</div>

I want to remove some WeakRef related resources, e.g. struct Blah dummy::String end a = Blah("abc") b = Dict() b\["a"\] = WeakRef(a) function do\_cleaning() for (k, v) in b if v.value == nothing …

---

## [CICLE FOR and DICTIONARY](https://discourse.julialang.org/t/cicle-for-and-dictionary/30614)

<div class="topic-metadata">

**Author:** [@Caterina\_Cerutti](https://discourse.julialang.org/u/Caterina_Cerutti)\
**Replies:** 2\
**Last updated:** [November 2, 2019, 10:18am UTC](https://discourse.julialang.org/t/cicle-for-and-dictionary/30614 "2019-11-02T10:18:55Z")

</div>

I have to write a FOR’s cicle from 1 to 100 and then I have to create a “Dict” ,Called squares, which contains as key the int number and as elements their squares. I have written For i in 1:100 Squares=Dict(i=\>i^2) E…

---

## [Resolving a module by its name?](https://discourse.julialang.org/t/resolving-a-module-by-its-name/30569)

<div class="topic-metadata">

**Author:** [@gcv](https://discourse.julialang.org/u/gcv)\
**Replies:** 9\
**Last updated:** [November 2, 2019, 5:51am UTC](https://discourse.julialang.org/t/resolving-a-module-by-its-name/30569 "2019-11-02T05:51:13Z")

</div>

Given an arbitrary module name as a symbol, and an expression, what is the correct way to evaluate the expression in the context of the module? For example, suppose I have the following tuple: in = (ns = :MyModule, exp…

---

## [The definition of free type variable](https://discourse.julialang.org/t/the-definition-of-free-type-variable/30575)

<div class="topic-metadata">

**Author:** [@alligatorme](https://discourse.julialang.org/u/alligatorme)\
**Replies:** 3\
**Last updated:** [November 1, 2019, 1:39pm UTC](https://discourse.julialang.org/t/the-definition-of-free-type-variable/30575 "2019-11-01T13:39:10Z")

</div>

In v1.2 manual, the free type varialbe is defined as “We say that a variable V is free in type T if T does not contain the UnionAll that introduces variable V.” But in the context, it seems to be “does” instead of “does…

---

## [Compiler determines return value(!) but still generates additional code](https://discourse.julialang.org/t/compiler-determines-return-value-but-still-generates-additional-code/27117)

<div class="topic-metadata">

**Author:** [@martink](https://discourse.julialang.org/u/martink)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 12:48am UTC](https://discourse.julialang.org/t/compiler-determines-return-value-but-still-generates-additional-code/27117 "2019-11-02T00:48:15Z")

</div>

Hello This is my first contribution to this Julia forum. I hope my issue belongs to the “Performance” category, if not i would be glad if someone can tell me a more appropriate place. I ran into an issue with a functio…

---

## [Optimization level when running files with include() in the REPL](https://discourse.julialang.org/t/optimization-level-when-running-files-with-include-in-the-repl/30566)

<div class="topic-metadata">

**Author:** [@aortizb](https://discourse.julialang.org/u/aortizb)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 12:30am UTC](https://discourse.julialang.org/t/optimization-level-when-running-files-with-include-in-the-repl/30566 "2019-11-02T00:30:15Z")

</div>

I know from the user manual that: julia -O -- file.jl has a default optimization level of 3. I have few questions regarding the optimization level: If “file.jl” is run in the REPL using: include("file.jl") what is…

---

## [Fitting a Weibull distribution to values](https://discourse.julialang.org/t/fitting-a-weibull-distribution-to-values/30600)

<div class="topic-metadata">

**Author:** [@ramonz](https://discourse.julialang.org/u/ramonz)\
**Replies:** 2\
**Last updated:** [November 1, 2019, 7:11pm UTC](https://discourse.julialang.org/t/fitting-a-weibull-distribution-to-values/30600 "2019-11-01T19:11:51Z")

</div>

Hello again I would like to fit a set of values to a Weibull distribution but the fitting is still not implemented in the Distributions.jl package for this type of Distribution Distribution Fitting · Distributions.jl. …

---

## [Does Julia run in Azure?](https://discourse.julialang.org/t/does-julia-run-in-azure/30589)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 4\
**Last updated:** [November 1, 2019, 3:30pm UTC](https://discourse.julialang.org/t/does-julia-run-in-azure/30589 "2019-11-01T15:30:00Z")

</div>

I confess – I have never used Azure, and know little of it. My understanding is that it involves using a web browser as a terminal window, and run code via distant log-in – using pre-installed software, and with flexibil…

---

## [Dot syntax for anonymous functions](https://discourse.julialang.org/t/dot-syntax-for-anonymous-functions/30581)

<div class="topic-metadata">

**Author:** [@ludwig-austermann](https://discourse.julialang.org/u/ludwig-austermann)\
**Replies:** 5\
**Last updated:** [November 1, 2019, 3:06pm UTC](https://discourse.julialang.org/t/dot-syntax-for-anonymous-functions/30581 "2019-11-01T15:06:18Z")

</div>

Hi, in mathematics we use this syntax of • to represent (anonymous) functions. For instance ||•|| is then equivalent to writing x |–\> ||x||. My question is, is there such syntax in julia? If not, I’d love to see the, …

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

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