# General Usage

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

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

**Page:** 902

---

## [Help wanted to track down a Cairo.jl problem](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738)

<div class="topic-metadata">

**Author:** [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Replies:** 17\
**Last updated:** [January 17, 2019, 7:13pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738 "2019-01-17T19:13:57Z")

</div>

Could anyone with a few minutes to spare help me investigate a problem with Cairo on macOS/Linux? Assuming you’ve installed Cairo successfully (and it’s been pre-compiled), run: using Cairo @time cr = CairoRGBSurface(2…

---

## [Updating of variables inside testset](https://discourse.julialang.org/t/updating-of-variables-inside-testset/19755)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [January 17, 2019, 6:58pm UTC](https://discourse.julialang.org/t/updating-of-variables-inside-testset/19755 "2019-01-17T18:58:42Z")

</div>

Hi everyone, I encountered this problem already multiple times and I don’t understand the reason for this behaviour. I don’t have a minimal working example, but the basic setup is the following: @testset "FirstSet" be…

---

## [Why does \`\[42\]\[\]\` work?](https://discourse.julialang.org/t/why-does-42-work/19722)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 6\
**Last updated:** [January 17, 2019, 6:15pm UTC](https://discourse.julialang.org/t/why-does-42-work/19722 "2019-01-17T18:15:34Z")

</div>

I’ve seen something like this in the JuliaAcademy Flux course: \[42\]\[\] It returns 42 but it doesn’t seem to work with any other type of array, ie \[42, 43\]\[\], nor \[42 43\]\[\], nor \[42; 43\]\[\]. What does this indexing do, m…

---

## [Round function for float](https://discourse.julialang.org/t/round-function-for-float/19753)

<div class="topic-metadata">

**Author:** [@leclere](https://discourse.julialang.org/u/leclere)\
**Replies:** 2\
**Last updated:** [January 17, 2019, 6:14pm UTC](https://discourse.julialang.org/t/round-function-for-float/19753 "2019-01-17T18:14:05Z")

</div>

I was surprised to see that round(3.14159,2) was no more available in julia 1.0. Is there any alternative ? (I saw that signif have also disappeared).

---

## [Writing a SIMD friendly iterate function](https://discourse.julialang.org/t/writing-a-simd-friendly-iterate-function/19472)

<div class="topic-metadata">

**Author:** [@rgankema](https://discourse.julialang.org/u/rgankema)\
**Replies:** 6\
**Last updated:** [January 17, 2019, 4:51pm UTC](https://discourse.julialang.org/t/writing-a-simd-friendly-iterate-function/19472 "2019-01-17T16:51:58Z")

</div>

Hi everyone, For a project I’m working on I have a datastructure with an AbstractArray interface that internally stores its data in a Vector of Vectors (more precisly, it uses a fixed-size arrays, but that doesn’t matte…

---

## [Noob question: why does attached code snippet work on JuliaBox but not JuliaPro?](https://discourse.julialang.org/t/noob-question-why-does-attached-code-snippet-work-on-juliabox-but-not-juliapro/19714)

<div class="topic-metadata">

**Author:** [@adannenberg](https://discourse.julialang.org/u/adannenberg)\
**Replies:** 11\
**Last updated:** [January 17, 2019, 12:43pm UTC](https://discourse.julialang.org/t/noob-question-why-does-attached-code-snippet-work-on-juliabox-but-not-juliapro/19714 "2019-01-17T12:43:45Z")

</div>

The backdrop: I’m starting to learn the language and am playing around with both JuliaBox and locally installed JuliaPro. Here’s a silly way to create 3x3 array of three 0s, 1s and 2s arranged randomly: using Random …

---

## [Why does subtype checks use \`\<:\` instead of just \`\<\`](https://discourse.julialang.org/t/why-does-subtype-checks-use-instead-of-just/19726)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 22\
**Last updated:** [January 17, 2019, 5:54am UTC](https://discourse.julialang.org/t/why-does-subtype-checks-use-instead-of-just/19726 "2019-01-17T05:54:04Z")

</div>

I was wondering why for checking subtype (I am not even sure that’s the right terminology) the operator is \<:. E.g Int \<: Integer returns true. But wouldn’t \< work as well syntacially? E.g. Int \< Integer. So my question…

---

## [Vector of matrices vs. multidimensional arrays](https://discourse.julialang.org/t/vector-of-matrices-vs-multidimensional-arrays/9602)

<div class="topic-metadata">

**Author:** [@plapplop](https://discourse.julialang.org/u/plapplop)\
**Replies:** 13\
**Last updated:** [January 17, 2019, 12:05pm UTC](https://discourse.julialang.org/t/vector-of-matrices-vs-multidimensional-arrays/9602 "2019-01-17T12:05:24Z")

</div>

I have to deal with 3 dimensional structures, I was hesitating between vectors of vectors of vectors, vectors of matrices or tridimensional arrays. For performance comparison, I wrote this small test: julia\> L = M = N =…

---

## [Julia-1.0.3 segfaults on this snippet, while julia-0.7 runs fine](https://discourse.julialang.org/t/julia-1-0-3-segfaults-on-this-snippet-while-julia-0-7-runs-fine/19736)

<div class="topic-metadata">

**Author:** [@abulak](https://discourse.julialang.org/u/abulak)\
**Replies:** 2\
**Last updated:** [January 17, 2019, 7:30am UTC](https://discourse.julialang.org/t/julia-1-0-3-segfaults-on-this-snippet-while-julia-0-7-runs-fine/19736 "2019-01-17T07:30:12Z")

</div>

julia\> versioninfo() Julia Version 0.7.0 Commit a4cb80f3ed (2018-08-08 06:46 UTC) Platform Info: OS: Linux (x86\_64-pc-linux-gnu) CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz WORD\_SIZE: 64 LIBM: libopenlibm LLV…

---

## [Converting 1×n array to n-vector](https://discourse.julialang.org/t/converting-1xn-array-to-n-vector/19723)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 5\
**Last updated:** [January 17, 2019, 1:14am UTC](https://discourse.julialang.org/t/converting-1xn-array-to-n-vector/19723 "2019-01-17T01:14:24Z")

</div>

I would like to convert a 1×n array to an n-vector, e.g., \[1 2 3\] to \[1,2,3\]. What is the best way to do so? My current method is first to convert it to a tuple and then to a vector: julia\> VERSION v"0.7.0" julia\> w …

---

## [Add all packages from 1.0.3 to 1.1](https://discourse.julialang.org/t/add-all-packages-from-1-0-3-to-1-1/19724)

<div class="topic-metadata">

**Author:** [@monty](https://discourse.julialang.org/u/monty)\
**Replies:** 4\
**Last updated:** [January 16, 2019, 9:54pm UTC](https://discourse.julialang.org/t/add-all-packages-from-1-0-3-to-1-1/19724 "2019-01-16T21:54:23Z")

</div>

How to add all the Packages already added under 1.0.3 when moving to 1.1.

---

## [What's the length of this array in Julia?](https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 1\
**Last updated:** [January 16, 2019, 7:25pm UTC](https://discourse.julialang.org/t/whats-the-length-of-this-array-in-julia/19718 "2019-01-16T19:25:08Z")

</div>

Suppose myObject is a defined type. The following is a part of my code. a=myObject() # calling the default constructor b=\[a\] println(length(b)) Should’t this give me 1? Because b is an array of only one element, wh…

---

## [Pkg - cloning from unregistered package, not updating](https://discourse.julialang.org/t/pkg-cloning-from-unregistered-package-not-updating/19720)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 12\
**Last updated:** [January 16, 2019, 8:39pm UTC](https://discourse.julialang.org/t/pkg-cloning-from-unregistered-package-not-updating/19720 "2019-01-16T20:39:24Z")

</div>

I’m trying to use an unregistered package and obtaining it from the GitHub repository by Pkg.clone(). However, it doesn’t appear to recognize that the repository has changed, and even when I delete the local copy in \\.ju…

---

## [@cfunction definition in a module/package](https://discourse.julialang.org/t/cfunction-definition-in-a-module-package/19557)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 3\
**Last updated:** [January 16, 2019, 6:23pm UTC](https://discourse.julialang.org/t/cfunction-definition-in-a-module-package/19557 "2019-01-16T18:23:20Z")

</div>

For working with tools around libcairo (and other gui stuff) it’s necessary to provide callback functions in C-API. I’m looking at a strange problem in front-porting from 0.6 to 1.0. Within the package/module (CairoScri…

---

## [Has anyone had success using Julia from Matlab?](https://discourse.julialang.org/t/has-anyone-had-success-using-julia-from-matlab/16661)

<div class="topic-metadata">

**Author:** [@zaen](https://discourse.julialang.org/u/zaen)\
**Replies:** 24\
**Last updated:** [January 16, 2019, 4:11pm UTC](https://discourse.julialang.org/t/has-anyone-had-success-using-julia-from-matlab/16661 "2019-01-16T16:11:20Z")

</div>

Continuing the discussion from Embedding Julia in Matlab: I’m trying to use Matlab’s foreign function interface (see the MATLAB loadlibrary function) to call Julia code from MATLAB. Has anyone been successful in doing t…

---

## [Add WebSockets package in Julia version 0.7](https://discourse.julialang.org/t/add-websockets-package-in-julia-version-0-7/19701)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 4\
**Last updated:** [January 16, 2019, 5:14pm UTC](https://discourse.julialang.org/t/add-websockets-package-in-julia-version-0-7/19701 "2019-01-16T17:14:53Z")

</div>

I’m using Julia 0.7 on Linux Ubuntu. julia\> Pkg.installed() Dict{String,Union{Nothing, VersionNumber}} with 3 entries: “Juno” =\> v"0.5.3" “Plots” =\> v"0.19.3" “Atom” =\> v"0.7.12" julia\> Pkg.add(PackageSpec(name …

---

## [Work around splatting to avoid unecessary allocations](https://discourse.julialang.org/t/work-around-splatting-to-avoid-unecessary-allocations/19708)

<div class="topic-metadata">

**Author:** [@konkam](https://discourse.julialang.org/u/konkam)\
**Replies:** 2\
**Last updated:** [January 16, 2019, 4:48pm UTC](https://discourse.julialang.org/t/work-around-splatting-to-avoid-unecessary-allocations/19708 "2019-01-16T16:48:19Z")

</div>

Hello everyone, I am trying to call Base.Iterators.product on a number of arguments which is not fixed in advance, i.e. to call the following function on integer vectors of arbitrary length. function indices\_below(Λ\_ma…

---

## [Segmentation fault on threadcall of cfunction from Julia function](https://discourse.julialang.org/t/segmentation-fault-on-threadcall-of-cfunction-from-julia-function/19707)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 0\
**Last updated:** [January 16, 2019, 3:44pm UTC](https://discourse.julialang.org/t/segmentation-fault-on-threadcall-of-cfunction-from-julia-function/19707 "2019-01-16T15:44:23Z")

</div>

Hi, I have a blocking function in a C++ library that I have wrapped using CxxWrap. I would like to start a thread calling this blocking function, so no Julia thread is blocked, using uv\_async\_send to signal a Julia asyn…

---

## [Transportation of network simulation offline using Julia (Package suggestions)](https://discourse.julialang.org/t/transportation-of-network-simulation-offline-using-julia-package-suggestions/19706)

<div class="topic-metadata">

**Author:** [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Replies:** 0\
**Last updated:** [January 16, 2019, 3:27pm UTC](https://discourse.julialang.org/t/transportation-of-network-simulation-offline-using-julia-package-suggestions/19706 "2019-01-16T15:27:11Z")

</div>

I’d like to simulate the movement of cars in a given map, for example, say in the attached following picture. I’d like to have several control buttons which control the start, stop, speed, etc of the car movements. Is t…

---

## [\`using\` on demand, is it possible?](https://discourse.julialang.org/t/using-on-demand-is-it-possible/19696)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 1\
**Last updated:** [January 16, 2019, 2:04pm UTC](https://discourse.julialang.org/t/using-on-demand-is-it-possible/19696 "2019-01-16T14:04:39Z")

</div>

Hi guys! I have a package that needs to use ODBC.jl for some tasks. However, the compilation time and import time is huge. Hence, I am wondering: is there a way to import packages “on demand”? For example, I just need t…

---

## [Approx with a weird behaviour](https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [January 16, 2019, 12:04pm UTC](https://discourse.julialang.org/t/approx-with-a-weird-behaviour/19690 "2019-01-16T12:04:43Z")

</div>

Why do these two statements give me different results? The first is false, the second is true. 0.0 ≈ 1.071327271687239e-17 1.0 ≈ 1.0 + 1.071327271687239e-17

---

## [Exporting symbols of imported module](https://discourse.julialang.org/t/exporting-symbols-of-imported-module/19651)

<div class="topic-metadata">

**Author:** [@blegat](https://discourse.julialang.org/u/blegat)\
**Replies:** 5\
**Last updated:** [January 16, 2019, 4:36am UTC](https://discourse.julialang.org/t/exporting-symbols-of-imported-module/19651 "2019-01-16T04:36:32Z")

</div>

Suppose I write a module A that imports another module B but I want users that do using A to also have access of symbols exported from B. If I do module B import A export A.x end then I get ERROR: LoadError: syntax: …

---

## [Avoid recalculating X^q when f(p): X.^1 ... X.^p](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491)

<div class="topic-metadata">

**Author:** [@taqtiqa-mark](https://discourse.julialang.org/u/taqtiqa-mark)\
**Replies:** 7\
**Last updated:** [January 16, 2019, 4:36am UTC](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491 "2019-01-16T04:36:10Z")

</div>

Wasn’t sure if this belongs in first-steps or performance - happy to move it… What is best practice implementation of the following in Julia. The objective is to minimize run time. There is no requirement that this be…

---

## [Memory error while using shared arrays](https://discourse.julialang.org/t/memory-error-while-using-shared-arrays/19606)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 6\
**Last updated:** [January 16, 2019, 2:21am UTC](https://discourse.julialang.org/t/memory-error-while-using-shared-arrays/19606 "2019-01-16T02:21:42Z")

</div>

Hi all, I have a fairly complicated bit of code involving shared arrays. I’m having problems with a memory error although can’t seem to get a minimum working example. Pseudo-code of what I am doing follows: # Set some …

---

## [Boolean short circuit "fusion"](https://discourse.julialang.org/t/boolean-short-circuit-fusion/19641)

<div class="topic-metadata">

**Author:** [@jackf](https://discourse.julialang.org/u/jackf)\
**Replies:** 20\
**Last updated:** [January 15, 2019, 11:40pm UTC](https://discourse.julialang.org/t/boolean-short-circuit-fusion/19641 "2019-01-15T23:40:59Z")

</div>

I have an array A. I want to test if there are any values in A satisfying some test: julia\> f1(x) = any(x .\> 99) Easy code to read, but inefficient since we allocate the whole boolean array. We could also define the f…

---

## [Return tuple of user chosen functions, metaprogramming?](https://discourse.julialang.org/t/return-tuple-of-user-chosen-functions-metaprogramming/19675)

<div class="topic-metadata">

**Author:** [@MrUrq](https://discourse.julialang.org/u/MrUrq)\
**Replies:** 5\
**Last updated:** [January 15, 2019, 9:42pm UTC](https://discourse.julialang.org/t/return-tuple-of-user-chosen-functions-metaprogramming/19675 "2019-01-15T21:42:45Z")

</div>

Hi, I have a problem where, after som expensive calculations, an anonymous function is created. The anonymous function needs to return a tuple of the results depending on the users input. Here is an example of what I wi…

---

## [Behavior of the pwd() statement, Windows 10](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673)

<div class="topic-metadata">

**Author:** [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)\
**Replies:** 8\
**Last updated:** [January 15, 2019, 7:21pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673 "2019-01-15T19:21:54Z")

</div>

Hello, The pwd statement has been discussed here before and I may not understand the answer. The following behavior can be found in the documentation: julia\> pwd() "/home/JuliaUser" When I execute the statement (Wind…

---

## [Poor performance due to memory allocations?](https://discourse.julialang.org/t/poor-performance-due-to-memory-allocations/19629)

<div class="topic-metadata">

**Author:** [@mirzadeh](https://discourse.julialang.org/u/mirzadeh)\
**Replies:** 17\
**Last updated:** [January 15, 2019, 6:36pm UTC](https://discourse.julialang.org/t/poor-performance-due-to-memory-allocations/19629 "2019-01-15T18:36:13Z")

</div>

Hello! I have recently started using Julia and decided to do a simple example to test my understanding of the language and performance pitfalls. The example is a simple Jacobi relaxation for solving the Poisson’s equati…

---

## [Comment seems to cause compiler error](https://discourse.julialang.org/t/comment-seems-to-cause-compiler-error/19671)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 3\
**Last updated:** [January 15, 2019, 6:00pm UTC](https://discourse.julialang.org/t/comment-seems-to-cause-compiler-error/19671 "2019-01-15T18:00:50Z")

</div>

This is odd. Looks like commenting out an entry in the array causes a parse error. I found this trying to do exactly that in my code, i.e. commenting out an entry to replace it with a more up-to-date set of values. jul…

---

## [Trying Rebugger: not able to track](https://discourse.julialang.org/t/trying-rebugger-not-able-to-track/19667)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 2\
**Last updated:** [January 15, 2019, 5:15pm UTC](https://discourse.julialang.org/t/trying-rebugger-not-able-to-track/19667 "2019-01-15T17:15:59Z")

</div>

I have some very simple code: g(x) = 1 + x What I want to do is use Rebugger.jl and step into g. The focus is on trying Rebugger and learning it and less on actually debugging anything. However, I get the following err…

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

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