# General Usage

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

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

**Page:** 1026

---

## [Using "√" with a vector](https://discourse.julialang.org/t/using-with-a-vector/6025)

<div class="topic-metadata">

**Author:** [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Replies:** 4\
**Last updated:** [September 22, 2017, 2:15am UTC](https://discourse.julialang.org/t/using-with-a-vector/6025 "2017-09-22T02:15:57Z")

</div>

I’m using Julia v0.6.0 and my old codes with √(x) where x is a Vector is giving warning as julia\> √(x) WARNING: sqrt{T \<: Number}(x::AbstractArray{T}) is deprecated, use sqrt.(x) instead. Stacktrace: \[1\] depwarn(::Stri…

---

## [Does declaring a variable to be constant do anything at all?](https://discourse.julialang.org/t/does-declaring-a-variable-to-be-constant-do-anything-at-all/6029)

<div class="topic-metadata">

**Author:** [@tparker](https://discourse.julialang.org/u/tparker)\
**Replies:** 10\
**Last updated:** [September 21, 2017, 11:07pm UTC](https://discourse.julialang.org/t/does-declaring-a-variable-to-be-constant-do-anything-at-all/6029 "2017-09-21T23:07:07Z")

</div>

The code const x = 4 x = 3 issues a warning but still changes the value of x. And you can change bits-type fields of constant instances of mutable types without even getting a warning: mutable struct Mut x::Int64 en…

---

## [Somewhat faster text/numeric io](https://discourse.julialang.org/t/somewhat-faster-text-numeric-io/5100)

<div class="topic-metadata">

**Author:** [@dgleich](https://discourse.julialang.org/u/dgleich)\
**Replies:** 1\
**Last updated:** [September 21, 2017, 9:26pm UTC](https://discourse.julialang.org/t/somewhat-faster-text-numeric-io/5100 "2017-09-21T21:26:47Z")

</div>

I had to read an 80GB file of text-formatted numbers recently on a machine with 2TB of RAM. So I just loaded the full text into memory (about 600s), and then had to get it into actual number. In my case, it was a mix of …

---

## [Question on ccall for complex types](https://discourse.julialang.org/t/question-on-ccall-for-complex-types/6024)

<div class="topic-metadata">

**Author:** [@wbhart](https://discourse.julialang.org/u/wbhart)\
**Replies:** 6\
**Last updated:** [September 21, 2017, 4:22pm UTC](https://discourse.julialang.org/t/question-on-ccall-for-complex-types/6024 "2017-09-21T16:22:42Z")

</div>

We are getting deprecation warnings for uses of & in ccall’s in Nemo.jl. It’s time we replaced them, but I don’t currently understand what is required. To make the question concrete, I give an example. On the C side we …

---

## [Updating an array inside a for loop- comparison with MATLAB](https://discourse.julialang.org/t/updating-an-array-inside-a-for-loop-comparison-with-matlab/750)

<div class="topic-metadata">

**Author:** [@Faber](https://discourse.julialang.org/u/Faber)\
**Replies:** 17\
**Last updated:** [September 21, 2017, 5:12am UTC](https://discourse.julialang.org/t/updating-an-array-inside-a-for-loop-comparison-with-matlab/750 "2017-09-21T05:12:34Z")

</div>

Dear all, thanks in advance for any reply. Coming from Matlab, new to julia, I was impressed by the benchmarks reported for Julia and thought to rewrite some of my codes in Julia. Before doing so I wanted to run a simp…

---

## [Broadcast for custom type](https://discourse.julialang.org/t/broadcast-for-custom-type/3497)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 10\
**Last updated:** [September 21, 2017, 4:06am UTC](https://discourse.julialang.org/t/broadcast-for-custom-type/3497 "2017-09-21T04:06:28Z")

</div>

I am using v0.6, this is an MWE of a question I want to solve. I would like to make broadcast work for a custom type struct CongruentVector{Td,Tv} descriptor::Td vector::Tv end the following way: given a metho…

---

## [Understand the pattern of multiple dispatch](https://discourse.julialang.org/t/understand-the-pattern-of-multiple-dispatch/5976)

<div class="topic-metadata">

**Author:** [@morningkyle](https://discourse.julialang.org/u/morningkyle)\
**Replies:** 4\
**Last updated:** [September 20, 2017, 5:32am UTC](https://discourse.julialang.org/t/understand-the-pattern-of-multiple-dispatch/5976 "2017-09-20T05:32:30Z")

</div>

Multiple dispatch is a famous feature of Julia. But I find I am a bit confused that some standard APIs do not embrace this feature as expected. Here is one example with code: julia\> max(1, 2, 3) 3 julia\> max.(\[1 2 3\]…

---

## [Unwanted allocations calling function stored in structure](https://discourse.julialang.org/t/unwanted-allocations-calling-function-stored-in-structure/6014)

<div class="topic-metadata">

**Author:** [@cstook](https://discourse.julialang.org/u/cstook)\
**Replies:** 2\
**Last updated:** [September 21, 2017, 1:29am UTC](https://discourse.julialang.org/t/unwanted-allocations-calling-function-stored-in-structure/6014 "2017-09-21T01:29:17Z")

</div>

Below is a toy example of my problem. The call b.f(1.0) allocates memory. Is it possible to call the function h inside FunctionHolder without allocations? struct FunctionHolder f :: Function end function main() …

---

## [Julia throws an Runtime Error when trying to use PyPlot](https://discourse.julialang.org/t/julia-throws-an-runtime-error-when-trying-to-use-pyplot/6002)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [September 21, 2017, 1:17am UTC](https://discourse.julialang.org/t/julia-throws-an-runtime-error-when-trying-to-use-pyplot/6002 "2017-09-21T01:17:53Z")

</div>

Does anyone know what this might be about? Restarting the computer did not help. using PyPlot x = \[1 2 3 4 5\] y = \[2 4 6 8 10\] plot(x,y)

---

## [Are immutable types always passed by copying?](https://discourse.julialang.org/t/are-immutable-types-always-passed-by-copying/6013)

<div class="topic-metadata">

**Author:** [@tparker](https://discourse.julialang.org/u/tparker)\
**Replies:** 1\
**Last updated:** [September 20, 2017, 11:50pm UTC](https://discourse.julialang.org/t/are-immutable-types-always-passed-by-copying/6013 "2017-09-20T23:50:39Z")

</div>

The documentation says An object with an immutable type is passed around (both in assignment statements and in function calls) by copying, whereas a mutable type is passed around by reference. Is this literally true,…

---

## [Nested loops are consuming a lot of memory](https://discourse.julialang.org/t/nested-loops-are-consuming-a-lot-of-memory/6010)

<div class="topic-metadata">

**Author:** [@tryingtosolve](https://discourse.julialang.org/u/tryingtosolve)\
**Replies:** 6\
**Last updated:** [September 20, 2017, 11:03pm UTC](https://discourse.julialang.org/t/nested-loops-are-consuming-a-lot-of-memory/6010 "2017-09-20T23:03:10Z")

</div>

I have a nested loop iteration scheme that’s taking up a lot of memory. I do understand that I should not have globals but even after I included everything in a function, the memory situation didn’t improve. It just accu…

---

## [REPL output for subtype of Function](https://discourse.julialang.org/t/repl-output-for-subtype-of-function/5997)

<div class="topic-metadata">

**Author:** [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Replies:** 1\
**Last updated:** [September 20, 2017, 3:15pm UTC](https://discourse.julialang.org/t/repl-output-for-subtype-of-function/5997 "2017-09-20T15:15:35Z")

</div>

How is one meant I override the default output in the REPL? This early thread Proper way to hook into REPL display of type seems to suggest using show, but this doesn’t work for subtypes of Function: julia\> struct Foo \<:…

---

## [Requests.post() is giving Certificate verification failed error](https://discourse.julialang.org/t/requests-post-is-giving-certificate-verification-failed-error/6001)

<div class="topic-metadata">

**Author:** [@antoperit](https://discourse.julialang.org/u/antoperit)\
**Replies:** 0\
**Last updated:** [September 20, 2017, 2:20pm UTC](https://discourse.julialang.org/t/requests-post-is-giving-certificate-verification-failed-error/6001 "2017-09-20T14:20:06Z")

</div>

Dear colleagues, I am using Julia v0.6 Calling Requests.post() for example: using Requests … rsp = post(“https://test.com/post”; headers = Dict(“Authorization”=\> “Basic udEB0YW5nZW50LndvcmtzOnRhbmdl==”),json = …

---

## [Authorize REST request if @ is in username](https://discourse.julialang.org/t/authorize-rest-request-if-is-in-username/5869)

<div class="topic-metadata">

**Author:** [@antoperit](https://discourse.julialang.org/u/antoperit)\
**Replies:** 2\
**Last updated:** [September 20, 2017, 2:20pm UTC](https://discourse.julialang.org/t/authorize-rest-request-if-is-in-username/5869 "2017-09-20T14:20:01Z")

</div>

Using post function from package Requests I have to authorize the communication. I follow recommendation in Requests.jl post(“http://username:password@httpbin.org/post”) However I have to use username in the form o…

---

## [Why would a fast computer run Julia slower than a slow computer?](https://discourse.julialang.org/t/why-would-a-fast-computer-run-julia-slower-than-a-slow-computer/5999)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 3\
**Last updated:** [September 20, 2017, 2:12pm UTC](https://discourse.julialang.org/t/why-would-a-fast-computer-run-julia-slower-than-a-slow-computer/5999 "2017-09-20T14:12:12Z")

</div>

I have two computers, both running Julia v0.6 on Windows 10 x64: My laptop is just shy of 4 years old. It has an intel i5-2400u @ 1.6GHz, 2 cores, 4 threads. With Geekbench, its single-core CPU score is 2985. My deskto…

---

## [Const fields in structs](https://discourse.julialang.org/t/const-fields-in-structs/5994)

<div class="topic-metadata">

**Author:** [@zweiglimmergneis](https://discourse.julialang.org/u/zweiglimmergneis)\
**Replies:** 4\
**Last updated:** [September 20, 2017, 9:44am UTC](https://discourse.julialang.org/t/const-fields-in-structs/5994 "2017-09-20T09:44:09Z")

</div>

Version 0.6.0 (2017-06-19 13:05 UTC) x86\_64-redhat-linux Am I right, that const fields are not supported? It is possible to define a struct with const fields, but how to create an instance of it? mutable struct F1 …

---

## [Writing a convert function with parametric types](https://discourse.julialang.org/t/writing-a-convert-function-with-parametric-types/5992)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 1\
**Last updated:** [September 20, 2017, 6:22am UTC](https://discourse.julialang.org/t/writing-a-convert-function-with-parametric-types/5992 "2017-09-20T06:22:49Z")

</div>

I’m trying to write a custom convert for FixedPointNumber and finding that I’m still on a learning curve. The goal is to be able to write convert(Fixed{Int16,12}, Fixed{Int16, 10}(0.2231)) And have it do the conversio…

---

## [Can julia have any method or package for descriptive statistics?](https://discourse.julialang.org/t/can-julia-have-any-method-or-package-for-descriptive-statistics/5990)

<div class="topic-metadata">

**Author:** [@nizhizhen](https://discourse.julialang.org/u/nizhizhen)\
**Replies:** 1\
**Last updated:** [September 20, 2017, 12:55am UTC](https://discourse.julialang.org/t/can-julia-have-any-method-or-package-for-descriptive-statistics/5990 "2017-09-20T00:55:31Z")

</div>

descriptive statistics

---

## [Embedding Julia in C++, segmentation fault during GC](https://discourse.julialang.org/t/embedding-julia-in-c-segmentation-fault-during-gc/5985)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 2\
**Last updated:** [September 19, 2017, 8:20pm UTC](https://discourse.julialang.org/t/embedding-julia-in-c-segmentation-fault-during-gc/5985 "2017-09-19T20:20:02Z")

</div>

I need to call a Julia function from C++ and get segmentation fault when Julia performs GC during the function. I don’t such an error if I manually disable GC for Julia. I have reduced it to a simple case where the probl…

---

## [Combine scarf plot and line plot in Gadfly or Plots](https://discourse.julialang.org/t/combine-scarf-plot-and-line-plot-in-gadfly-or-plots/5983)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 1\
**Last updated:** [September 19, 2017, 6:39pm UTC](https://discourse.julialang.org/t/combine-scarf-plot-and-line-plot-in-gadfly-or-plots/5983 "2017-09-19T18:39:57Z")

</div>

I would like to plot some time series data on line plot combined with a scarf plot. A scarf plot represents discrete events with blocks of color. The closest solution I found involves the vline geometry in Gadfly to crea…

---

## [How to convert array with hex to string?](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980)

<div class="topic-metadata">

**Author:** [@hvillalo](https://discourse.julialang.org/u/hvillalo)\
**Replies:** 2\
**Last updated:** [September 19, 2017, 5:23pm UTC](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980 "2017-09-19T17:23:22Z")

</div>

Hi, I’m trying to convert part of an array to a string. In the example below, I want to obtain the string: “GPT 120 kHz” from the following array: julia\> m\[853:863\] 11-element Array{UInt8,1}: 0x47 0x50 0x54 0x20 …

---

## [Reductions along dimension for tuples](https://discourse.julialang.org/t/reductions-along-dimension-for-tuples/5981)

<div class="topic-metadata">

**Author:** [@morningkyle](https://discourse.julialang.org/u/morningkyle)\
**Replies:** 2\
**Last updated:** [September 19, 2017, 4:55pm UTC](https://discourse.julialang.org/t/reductions-along-dimension-for-tuples/5981 "2017-09-19T16:55:16Z")

</div>

The title suites my report, so I made a reply here. Should I expect an ERROR for the 2nd function call as the 4th? I don’t get the sense of the return value of the 2nd. (Version 0.7.0-DEV.1816 (2017-09-17 15:48 UTC)) …

---

## [How to convert Array Any to String?](https://discourse.julialang.org/t/how-to-convert-array-any-to-string/5951)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 1\
**Last updated:** [September 18, 2017, 6:00pm UTC](https://discourse.julialang.org/t/how-to-convert-array-any-to-string/5951 "2017-09-18T18:00:10Z")

</div>

How to convert Array Any to String ? julia\> x=\[1,2,3,“a”\] 4-element Array{Any,1}: 1 2 3 “a” julia\> convert(Array{String},x) ERROR: MethodError: Cannot convert an object of type Int64 to an object of type String …

---

## [Is possible to create own time format for day with 26 hours?](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 8\
**Last updated:** [September 18, 2017, 5:50pm UTC](https://discourse.julialang.org/t/is-possible-to-create-own-time-format-for-day-with-26-hours/5917 "2017-09-18T17:50:38Z")

</div>

Is possible to create own time format for day with 26 hours ? Typical time : julia\> x=Dates.DateTime(“20140529 230000”, “yyyymmdd HHMMSS”) 2014-05-29T23:00:00 In my system day starting at 02:00:00 and end of day is a…

---

## [Why Union{} \<: Tuple?](https://discourse.julialang.org/t/why-union-tuple/5946)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [September 18, 2017, 3:06pm UTC](https://discourse.julialang.org/t/why-union-tuple/5946 "2017-09-18T15:06:34Z")

</div>

Why is Union{} \<: Tuple? When Base.Broadcast.\_broadcast\_eltype returns Union{}, what does that mean? That it could not infer an eltype? On v"0.6.0".

---

## [Fatal error after include-workspace-include](https://discourse.julialang.org/t/fatal-error-after-include-workspace-include/4258)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 8\
**Last updated:** [September 18, 2017, 2:15pm UTC](https://discourse.julialang.org/t/fatal-error-after-include-workspace-include/4258 "2017-09-18T14:15:44Z")

</div>

I get a rather weird reproducible error that crashes Julia in REPL and freezes it in Jupyter. The error happens whenever I use include followed by workspace then include again. I am using v0.50. The code I run is: incl…

---

## [Flush REPL (also inside Atom)](https://discourse.julialang.org/t/flush-repl-also-inside-atom/5947)

<div class="topic-metadata">

**Author:** [@bbrunaud](https://discourse.julialang.org/u/bbrunaud)\
**Replies:** 1\
**Last updated:** [September 18, 2017, 1:58pm UTC](https://discourse.julialang.org/t/flush-repl-also-inside-atom/5947 "2017-09-18T13:58:12Z")

</div>

Hello, is there a way to flush everything that is in memory and get a fresh REPL without doing CTRL+D and running the julia command again?. Running in a console it is not too much trouble, but I while inside Atom (Juno),…

---

## [Plot pane doesn't show the first plot command](https://discourse.julialang.org/t/plot-pane-doesnt-show-the-first-plot-command/5940)

<div class="topic-metadata">

**Author:** [@yha](https://discourse.julialang.org/u/yha)\
**Replies:** 1\
**Last updated:** [September 18, 2017, 5:19am UTC](https://discourse.julialang.org/t/plot-pane-doesnt-show-the-first-plot-command/5940 "2017-09-18T05:19:55Z")

</div>

When I run the following block of code with alt+Enter: using Plots pyplot() # or plotlyjs() plot(cumsum(randn(1000))) on a fresh Julia console (freshly opened Juno, or after killing the Julia process), nothing appears…

---

## [Clarification on type piracy](https://discourse.julialang.org/t/clarification-on-type-piracy/5926)

<div class="topic-metadata">

**Author:** [@wbhart](https://discourse.julialang.org/u/wbhart)\
**Replies:** 38\
**Last updated:** [September 17, 2017, 8:47pm UTC](https://discourse.julialang.org/t/clarification-on-type-piracy/5926 "2017-09-17T20:47:36Z")

</div>

In the style guide, it talks about type piracy \[1\], the practice of extending or redefining methods on types you didn’t define. We’ve been told in the past not to do this, especially with methods and types defined by Bas…

---

## [Documenter.jl travis.genkeys "which which" error on Windows?](https://discourse.julialang.org/t/documenter-jl-travis-genkeys-which-which-error-on-windows/5881)

<div class="topic-metadata">

**Author:** [@Crghilardi](https://discourse.julialang.org/u/Crghilardi)\
**Replies:** 5\
**Last updated:** [September 17, 2017, 3:24pm UTC](https://discourse.julialang.org/t/documenter-jl-travis-genkeys-which-which-error-on-windows/5881 "2017-09-17T15:24:49Z")

</div>

Hi all, I am trying my best to move over to Documenter from simple .md files and I have been struggling with the (seemingly) last few steps to get it up and running. When using documenter, I cannot generate the Travis k…

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

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