# General Usage

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

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

**Page:** 402

---

## [Last function](https://discourse.julialang.org/t/last-function/86741)

<div class="topic-metadata">

**Author:** [@reewa\_malik](https://discourse.julialang.org/u/reewa_malik)\
**Replies:** 4\
**Last updated:** [September 3, 2022, 11:21pm UTC](https://discourse.julialang.org/t/last-function/86741 "2022-09-03T23:21:20Z")

</div>

x=“abcd” last(x)==“d” This is giving me false as output, can anybody explain why??

---

## [How to decompress .xz files/ How to use streams?](https://discourse.julialang.org/t/how-to-decompress-xz-files-how-to-use-streams/86307)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 6\
**Last updated:** [September 3, 2022, 11:00pm UTC](https://discourse.julialang.org/t/how-to-decompress-xz-files-how-to-use-streams/86307 "2022-09-03T23:00:32Z")

</div>

I have the following code for unpacking .xz compressed files: using CodecXz function decompress(in, out) stream = open(in) output = open(out,"w") for line in eachline(XzDecompressorStream(stream)) p…

---

## [StatsBase sample throws first element when probabilities are zero](https://discourse.julialang.org/t/statsbase-sample-throws-first-element-when-probabilities-are-zero/86716)

<div class="topic-metadata">

**Author:** [@mwilinski](https://discourse.julialang.org/u/mwilinski)\
**Replies:** 2\
**Last updated:** [September 3, 2022, 9:51pm UTC](https://discourse.julialang.org/t/statsbase-sample-throws-first-element-when-probabilities-are-zero/86716 "2022-09-03T21:51:42Z")

</div>

I noticed that when provided with zero probabilities, sample (from StatsBase) always throws the first element. One can see it in the following example: using StatsBase println(sample(\[2, 3, 1\], ProbabilityWeights(\[0.0,…

---

## [Is @evalpoly needed anymore?](https://discourse.julialang.org/t/is-evalpoly-needed-anymore/86732)

<div class="topic-metadata">

**Author:** [@shmiggles](https://discourse.julialang.org/u/shmiggles)\
**Replies:** 1\
**Last updated:** [September 3, 2022, 4:14pm UTC](https://discourse.julialang.org/t/is-evalpoly-needed-anymore/86732 "2022-09-03T16:14:45Z")

</div>

Julia provides two ways of polynomial evaluation: one as a function (evalpoly) and the other as a macro (@evalpoly). My understanding is that the macro can (sometimes) be faster than the function due to inlining. However…

---

## [Package badges on JuliaHub](https://discourse.julialang.org/t/package-badges-on-juliahub/44635)

<div class="topic-metadata">

**Author:** [@avik](https://discourse.julialang.org/u/avik)\
**Replies:** 1\
**Last updated:** [September 3, 2022, 1:33pm UTC](https://discourse.julialang.org/t/package-badges-on-juliahub/44635 "2022-09-03T13:33:04Z")

</div>

Since JuliaHub collates a lot of information about packages, we thought it might be valuable to expose some of that via badges. So we’re pleased to announce that it now hosts badges for a packages latest release version …

---

## [How to add docstring to a function on an empty module?](https://discourse.julialang.org/t/how-to-add-docstring-to-a-function-on-an-empty-module/86728)

<div class="topic-metadata">

**Author:** [@uje](https://discourse.julialang.org/u/uje)\
**Replies:** 1\
**Last updated:** [September 3, 2022, 12:50pm UTC](https://discourse.julialang.org/t/how-to-add-docstring-to-a-function-on-an-empty-module/86728 "2022-09-03T12:50:47Z")

</div>

How do I add a docstring to the function add on this module that does not import Core and Base? julia\> Animal = Module(:Animal, false, false) Main.Animal julia\> @eval Animal add(x, y) = $(+)(x, y) add (generic function…

---

## [Ship custom sysimages created with PackageCompiler](https://discourse.julialang.org/t/ship-custom-sysimages-created-with-packagecompiler/86515)

<div class="topic-metadata">

**Author:** [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Replies:** 7\
**Last updated:** [September 3, 2022, 10:43am UTC](https://discourse.julialang.org/t/ship-custom-sysimages-created-with-packagecompiler/86515 "2022-09-03T10:43:14Z")

</div>

Currently I use PrecompilePlutoCourse to reduce latency of some Pluto notebooks for teaching. This is great, except that every student needs to wait quite a while for the PackageCompiler to finish. As there are at least …

---

## [Plot GPArray/ Arrayfire](https://discourse.julialang.org/t/plot-gparray-arrayfire/5423)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 4\
**Last updated:** [September 3, 2022, 7:59am UTC](https://discourse.julialang.org/t/plot-gparray-arrayfire/5423 "2022-09-03T07:59:36Z")

</div>

Hi, Is there a way to display 1d/2d arrays hosted by the GPU (aka with GPUArrays or ArrayFire)? ArrayFire has some method for that but it is a bit limited, Thank you for your help, Best regards Romain

---

## [Why the weird summarysize results for Rational{BigInt}](https://discourse.julialang.org/t/why-the-weird-summarysize-results-for-rational-bigint/86704)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [September 3, 2022, 4:51am UTC](https://discourse.julialang.org/t/why-the-weird-summarysize-results-for-rational-bigint/86704 "2022-09-03T04:51:01Z")

</div>

julia\> n = big"3"^100000; julia\> t = (n // 1, n, Rational{BigInt}(n)); julia\> typeof(t) Tuple{Rational{BigInt}, BigInt, Rational{BigInt}} julia\> map(Base.summarysize, t) (19872, 19968, 20008) julia\> first(t) == last(…

---

## [Creating a rasterized 3D surface plots inside vectorized figure](https://discourse.julialang.org/t/creating-a-rasterized-3d-surface-plots-inside-vectorized-figure/86569)

<div class="topic-metadata">

**Author:** [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Replies:** 4\
**Last updated:** [September 3, 2022, 4:00am UTC](https://discourse.julialang.org/t/creating-a-rasterized-3d-surface-plots-inside-vectorized-figure/86569 "2022-09-03T04:00:26Z")

</div>

I need to create a multi-panel figure which consists of 3D surface plots and normal 2D plots. In order to reduce file size, I want to rasterize the 3D surface plots, while keeping everything else (axes, texts, line plots…

---

## [Adapting code from Plots into PlotlyJS](https://discourse.julialang.org/t/adapting-code-from-plots-into-plotlyjs/78127)

<div class="topic-metadata">

**Author:** [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Replies:** 12\
**Last updated:** [September 3, 2022, 12:05am UTC](https://discourse.julialang.org/t/adapting-code-from-plots-into-plotlyjs/78127 "2022-09-03T00:05:24Z")

</div>

Hi, Using Plots, I have a simple old piece of code to plot a function with a parameter assuming different values. I want to plot it using PlotlyJS. I know how to do it trace-by-trace, but that is ugly and inefficient. H…

---

## [Packages and workers](https://discourse.julialang.org/t/packages-and-workers/14072)

<div class="topic-metadata">

**Author:** [@teored90](https://discourse.julialang.org/u/teored90)\
**Replies:** 15\
**Last updated:** [September 2, 2022, 10:07pm UTC](https://discourse.julialang.org/t/packages-and-workers/14072 "2022-09-02T22:07:25Z")

</div>

I don’t understand how to import a package that I generated on multiple workers on Julia v1.0. Steps to reproduce: Follow the documentation to create the HelloWorld package. Start Julia with -p 2. Activate the environ…

---

## [How to avoid allocations when reading arbitrary keys from a NamedTuple?](https://discourse.julialang.org/t/how-to-avoid-allocations-when-reading-arbitrary-keys-from-a-namedtuple/71806)

<div class="topic-metadata">

**Author:** [@mattwigway](https://discourse.julialang.org/u/mattwigway)\
**Replies:** 8\
**Last updated:** [September 2, 2022, 9:00pm UTC](https://discourse.julialang.org/t/how-to-avoid-allocations-when-reading-arbitrary-keys-from-a-namedtuple/71806 "2022-09-02T21:00:01Z")

</div>

I have a situation where I’m processing rowwise data from a JuliaDB table in a reducer. I’m having trouble with type stability, because my function looks like: function (row, col) value = row\[col\] ...do things wit…

---

## [Any small example of a queue like system, where a function is automatically executed when a new item pops in the queue?](https://discourse.julialang.org/t/any-small-example-of-a-queue-like-system-where-a-function-is-automatically-executed-when-a-new-item-pops-in-the-queue/86616)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 12\
**Last updated:** [September 2, 2022, 8:31pm UTC](https://discourse.julialang.org/t/any-small-example-of-a-queue-like-system-where-a-function-is-automatically-executed-when-a-new-item-pops-in-the-queue/86616 "2022-09-02T20:31:38Z")

</div>

Hello! I have some Julia code which detects when new files are made in a folder. The name of these files are then passed to a vector. Whenever a new item enters the vector, I wish to have a function detect this and run …

---

## [How to make custom REPL completion?](https://discourse.julialang.org/t/how-to-make-custom-repl-completion/86673)

<div class="topic-metadata">

**Author:** [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Replies:** 5\
**Last updated:** [September 2, 2022, 2:51pm UTC](https://discourse.julialang.org/t/how-to-make-custom-repl-completion/86673 "2022-09-02T14:51:22Z")

</div>

I would like to create a REPL with customised completion behaviour. Is there a tutorial, API documentations or similar about this somewhere?

---

## [Is there any package / method / function to determine and Solve Limits Problem in Julia?](https://discourse.julialang.org/t/is-there-any-package-method-function-to-determine-and-solve-limits-problem-in-julia/86678)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 8\
**Last updated:** [September 2, 2022, 2:26pm UTC](https://discourse.julialang.org/t/is-there-any-package-method-function-to-determine-and-solve-limits-problem-in-julia/86678 "2022-09-02T14:26:20Z")

</div>

Hi all, I was thinking plotting the graph is a nice solution to know a limit of a function, I have this problem from Calculus book: \\lim\_{\\theta \\rightarrow 0} \\frac{\\sin^{2} \\theta}{\\theta^{2}} (I think by hand we ca…

---

## [FLoops causing deep copy error with log message in loop](https://discourse.julialang.org/t/floops-causing-deep-copy-error-with-log-message-in-loop/86683)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 0\
**Last updated:** [September 2, 2022, 10:52am UTC](https://discourse.julialang.org/t/floops-causing-deep-copy-error-with-log-message-in-loop/86683 "2022-09-02T10:52:46Z")

</div>

Having a log message inside an @floop gives a deep copy error. Is this expected behaviour? julia\> using FLoops julia\> @floop for \_ in 1:24 @info Threads.threadid() sleep(1) end ERROR: LoadEr…

---

## [ubuntu deployment of up to date version](https://discourse.julialang.org/t/ubuntu-deployment-of-up-to-date-version/86496)

<div class="topic-metadata">

**Author:** [@eoli3n](https://discourse.julialang.org/u/eoli3n)\
**Replies:** 6\
**Last updated:** [September 1, 2022, 9:40pm UTC](https://discourse.julialang.org/t/ubuntu-deployment-of-up-to-date-version/86496 "2022-09-01T21:40:11Z")

</div>

I need to automate deployment of julia for 800 hosts for a University. On latest Ubuntu LTS, when I apt install julia it tells me to snap install julia. On snapcraft, julia package seems to be official but it is in a 2…

---

## [How to create an IOBuffer backed by a String](https://discourse.julialang.org/t/how-to-create-an-iobuffer-backed-by-a-string/86657)

<div class="topic-metadata">

**Author:** [@Ben\_Little](https://discourse.julialang.org/u/Ben_Little)\
**Replies:** 2\
**Last updated:** [September 1, 2022, 8:10pm UTC](https://discourse.julialang.org/t/how-to-create-an-iobuffer-backed-by-a-string/86657 "2022-09-01T20:10:12Z")

</div>

Probably unnecessary backstory: I need to read a bunch of files from a zip archive and then pass them to a Threads.@threads for loop. Unfortunately this doesn’t work. My guess is that the datatype created by ZipFile is n…

---

## [Priority queue choice](https://discourse.julialang.org/t/priority-queue-choice/42783)

<div class="topic-metadata">

**Author:** [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Replies:** 24\
**Last updated:** [September 1, 2022, 6:49pm UTC](https://discourse.julialang.org/t/priority-queue-choice/42783 "2022-09-01T18:49:44Z")

</div>

I need a performant implementation of a PriorityQueue{Int,Float64}. For Int you can think pixels and for Float64 think random times. Is this PriorityQueue from DataStructures.jl the right thing or are there maybe other …

---

## [Struct default value in constructor](https://discourse.julialang.org/t/struct-default-value-in-constructor/86648)

<div class="topic-metadata">

**Author:** [@Renan\_Rabelo](https://discourse.julialang.org/u/Renan_Rabelo)\
**Replies:** 6\
**Last updated:** [September 1, 2022, 7:08pm UTC](https://discourse.julialang.org/t/struct-default-value-in-constructor/86648 "2022-09-01T19:08:49Z")

</div>

I need the following struct: struct Foo bar baz qux = bar + baz The problem is that in constructor I need to set the value of “qux”, and I want the value only depend on “bar” and “baz”. How can instantiate…

---

## [\`read!\` and scalar variables](https://discourse.julialang.org/t/read-and-scalar-variables/86619)

<div class="topic-metadata">

**Author:** [@ChauhanT](https://discourse.julialang.org/u/ChauhanT)\
**Replies:** 4\
**Last updated:** [September 1, 2022, 7:03pm UTC](https://discourse.julialang.org/t/read-and-scalar-variables/86619 "2022-09-01T19:03:22Z")

</div>

Hi, Is there a specific reason why read! does not accept scalars ? The signature allows for the AbstractArray type, but not scalars. So essentially, this works: ios = open("./proprietary.format") ver = Array{UInt32}(u…

---

## [Fast(er) priority queues?](https://discourse.julialang.org/t/fast-er-priority-queues/81269)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 20\
**Last updated:** [September 1, 2022, 6:47pm UTC](https://discourse.julialang.org/t/fast-er-priority-queues/81269 "2022-09-01T18:47:11Z")

</div>

Hi there! Recently I wanted to accelerate Dijkstra’s algorithm, and I ended up implementing a really dumb priority queue based on two sorted vectors. Surprisingly, in some settings, it significantly speeds up the algori…

---

## [REPL in Vim](https://discourse.julialang.org/t/repl-in-vim/86649)

<div class="topic-metadata">

**Author:** [@pedro.rafae](https://discourse.julialang.org/u/pedro.rafae)\
**Replies:** 2\
**Last updated:** [September 1, 2022, 6:43pm UTC](https://discourse.julialang.org/t/repl-in-vim/86649 "2022-09-01T18:43:15Z")

</div>

Dear friends, what’s the best way to invoke Julia’s REPL for someone using the Vim editor? I’m using the Julia plugin for Vim, but I always have to be compiling the Julia code. I would like to know if there is any inter…

---

## [Trying to use map function in Threads](https://discourse.julialang.org/t/trying-to-use-map-function-in-threads/86603)

<div class="topic-metadata">

**Author:** [@jmurga](https://discourse.julialang.org/u/jmurga)\
**Replies:** 6\
**Last updated:** [September 1, 2022, 4:30pm UTC](https://discourse.julialang.org/t/trying-to-use-map-function-in-threads/86603 "2022-09-01T16:30:14Z")

</div>

Hi guys, I am trying to parallelize a computation using Threads instead of processes. I have tested my functions several times using Distributed package, and everything is working as expected with pmap(). I was trying …

---

## [How to utilize "MKLSparse.jl"?](https://discourse.julialang.org/t/how-to-utilize-mklsparse-jl/85263)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 14\
**Last updated:** [September 1, 2022, 3:56pm UTC](https://discourse.julialang.org/t/how-to-utilize-mklsparse-jl/85263 "2022-09-01T15:56:08Z")

</div>

I have some sparse matrices and I thought using “MKLSparse.jl” could faster the execution, but it did not. However, in the documentation, there is this note The integer type that should be used in order for MKL to be …

---

## [Error when using StatsPlots](https://discourse.julialang.org/t/error-when-using-statsplots/86646)

<div class="topic-metadata">

**Author:** [@Abdou](https://discourse.julialang.org/u/Abdou)\
**Replies:** 0\
**Last updated:** [September 1, 2022, 3:38pm UTC](https://discourse.julialang.org/t/error-when-using-statsplots/86646 "2022-09-01T15:38:38Z")

</div>

I’ve just installed Julia 1.8 and added StatPlots to my packages but when I try to use this package I get this errors ERROR: LoadError: InitError: could not load library “C:\\Users\\username.julia\\artifacts\\79e8b1aff46d44…

---

## [Is cis returning correct results?](https://discourse.julialang.org/t/is-cis-returning-correct-results/86641)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 3\
**Last updated:** [September 1, 2022, 2:03pm UTC](https://discourse.julialang.org/t/is-cis-returning-correct-results/86641 "2022-09-01T14:03:44Z")

</div>

Maybe I am doing something wrong in my reasoning, but analytically cis(x\*y) == cis(x)^y In code: julia\> # Using Float julia\> cis(5e7 \* 2.0) -0.3633850893556905 + 0.931639027109726im julia\> cis(5e7) ^ 2.0 -0.3633850893…

---

## [Plot The Squeeze Theorem Correctly](https://discourse.julialang.org/t/plot-the-squeeze-theorem-correctly/86585)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 5\
**Last updated:** [September 1, 2022, 1:20pm UTC](https://discourse.julialang.org/t/plot-the-squeeze-theorem-correctly/86585 "2022-09-01T13:20:47Z")

</div>

Hi all, I am trying to plot something to follow the Squeeze Theorem. It turns out to become funny. using Plots, LaTeXStrings pyplot(fmt=:svg) function pitick(start, stop, denom; mode=:text) a = Int(cld(start, π/de…

---

## [Package on gitlab not github](https://discourse.julialang.org/t/package-on-gitlab-not-github/86637)

<div class="topic-metadata">

**Author:** [@Barvid](https://discourse.julialang.org/u/Barvid)\
**Replies:** 10\
**Last updated:** [September 1, 2022, 12:48pm UTC](https://discourse.julialang.org/t/package-on-gitlab-not-github/86637 "2022-09-01T12:48:08Z")

</div>

Hello I was ask to make some julia code in my company. The main page 5. Creating Packages · Pkg.jl tell me to use User Guide · PkgTemplates.jl . All need githup. We are not allowed to use githup in my company. My comp…

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

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