# General Usage

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

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

**Page:** 1046

---

## [Nice way to display functions](https://discourse.julialang.org/t/nice-way-to-display-functions/4089)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 7\
**Last updated:** [June 6, 2017, 8:03pm UTC](https://discourse.julialang.org/t/nice-way-to-display-functions/4089 "2017-06-06T20:03:54Z")

</div>

i have a type that takes an anonymous function and want nice output for the display function. The anonymous functions should be really short, so showing the source or some kind of compressed syntax tree would be an opti…

---

## [Win32 bit versus Win64 bit Julia](https://discourse.julialang.org/t/win32-bit-versus-win64-bit-julia/4110)

<div class="topic-metadata">

**Author:** [@gopal2017](https://discourse.julialang.org/u/gopal2017)\
**Replies:** 5\
**Last updated:** [June 6, 2017, 6:08pm UTC](https://discourse.julialang.org/t/win32-bit-versus-win64-bit-julia/4110 "2017-06-06T18:08:15Z")

</div>

Hi, My code is working on Win64 Bit Julia but not on Win32 Bit Julia. It is giving TypeError:typeassert. What would be the reason? A program is working on Win64 but not on Win32. Thanks,

---

## [ERROR: GitError(Code:ERROR, Class:OS, failed to send request: A connection with the server could not be established](https://discourse.julialang.org/t/error-giterror-code-error-class-os-failed-to-send-request-a-connection-with-the-server-could-not-be-established/4114)

<div class="topic-metadata">

**Author:** [@jsschlosser](https://discourse.julialang.org/u/jsschlosser)\
**Replies:** 0\
**Last updated:** [June 6, 2017, 3:53pm UTC](https://discourse.julialang.org/t/error-giterror-code-error-class-os-failed-to-send-request-a-connection-with-the-server-could-not-be-established/4114 "2017-06-06T15:53:49Z")

</div>

When I try to use Pkg.add() for any repos and Pkg.init() I get the following error. I am using windows 7. I have Set the proxy settings for the firewall walk around, but nothing seems to have changed. julia\> Pkg.add(“Pl…

---

## [Help improve my threaded map function?](https://discourse.julialang.org/t/help-improve-my-threaded-map-function/4112)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 0\
**Last updated:** [June 6, 2017, 3:21pm UTC](https://discourse.julialang.org/t/help-improve-my-threaded-map-function/4112 "2017-06-06T15:21:02Z")

</div>

I tried writing a @thread’ed map function for array arguments. Very roughly imitating the general idea for how I see Base.map handles inferring the type of the result, I came up with, function tmap(f,args::AbstractArray…

---

## [Is this a bug? relevant for \> 0.4.6](https://discourse.julialang.org/t/is-this-a-bug-relevant-for-0-4-6/4030)

<div class="topic-metadata">

**Author:** [@Rudolf\_Sykora](https://discourse.julialang.org/u/Rudolf_Sykora)\
**Replies:** 11\
**Last updated:** [June 6, 2017, 12:43pm UTC](https://discourse.julialang.org/t/is-this-a-bug-relevant-for-0-4-6/4030 "2017-06-06T12:43:58Z")

</div>

Hello, the following code behaves unexpectedly: if 1\>0 beta = 0.5 print(“1. beta=”,beta,“\\n”) for i1=1:2 end print("2. beta = ", beta, “\\n”) end print("3. beta = ", beta, “\\n”) It produces: beta=beta beta = b…

---

## [Julia 0.6 parametric typealias](https://discourse.julialang.org/t/julia-0-6-parametric-typealias/4093)

<div class="topic-metadata">

**Author:** [@tawheeler](https://discourse.julialang.org/u/tawheeler)\
**Replies:** 5\
**Last updated:** [June 6, 2017, 8:35am UTC](https://discourse.julialang.org/t/julia-0-6-parametric-typealias/4093 "2017-06-06T08:35:08Z")

</div>

I am having trouble changing a typealias from julia 0.5 to a const declaration in Julia 0.6: typealias MyType Vector{PriorityQueue{Vector{Int}, Float64}} When I write const MyType = Vector{PriorityQueue{Vector{Int}, F…

---

## [Using Unitful.jl with imported dataframes?](https://discourse.julialang.org/t/using-unitful-jl-with-imported-dataframes/3957)

<div class="topic-metadata">

**Author:** [@Crghilardi](https://discourse.julialang.org/u/Crghilardi)\
**Replies:** 6\
**Last updated:** [June 6, 2017, 8:21am UTC](https://discourse.julialang.org/t/using-unitful-jl-with-imported-dataframes/3957 "2017-06-06T08:21:24Z")

</div>

I was wondering how to most efficiently write functions that can take different units of measure. My first approach to this would be to use a parameter in the function and if logic to switch as needed. #A goofy example…

---

## [Is multiple inheritance allowed (or to be allowed) in Julia?](https://discourse.julialang.org/t/is-multiple-inheritance-allowed-or-to-be-allowed-in-julia/4096)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 4\
**Last updated:** [June 6, 2017, 3:03am UTC](https://discourse.julialang.org/t/is-multiple-inheritance-allowed-or-to-be-allowed-in-julia/4096 "2017-06-06T03:03:31Z")

</div>

I am faced with an application which could use multiple inheritance to avoid repetition and arbitrariness in the type tree structure. As you know, multiple inheritance is nice to have when there 2 or more independent way…

---

## [Status of Threads](https://discourse.julialang.org/t/status-of-threads/3729)

<div class="topic-metadata">

**Author:** [@goldfita](https://discourse.julialang.org/u/goldfita)\
**Replies:** 20\
**Last updated:** [June 6, 2017, 2:56am UTC](https://discourse.julialang.org/t/status-of-threads/3729 "2017-06-06T02:56:57Z")

</div>

Does anyone know what the status of threads are? The following either terminates or hangs Julia 0.5.1 depending on N. I can’t use processes because I’m calling into a C routine that needs all memory in a single process…

---

## [\`@parallel\` macro](https://discourse.julialang.org/t/parallel-macro/4059)

<div class="topic-metadata">

**Author:** [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Replies:** 2\
**Last updated:** [June 5, 2017, 7:28am UTC](https://discourse.julialang.org/t/parallel-macro/4059 "2017-06-05T07:28:16Z")

</div>

I have been trying to understand how @parallel works for some time now, but I have not been able to reason why the below code works the way it works: julia\> nprocs() 4 julia\> res = @parallel (+) for n in 1:3 n…

---

## [How do you make anonymous module w/ variables?](https://discourse.julialang.org/t/how-do-you-make-anonymous-module-w-variables/4068)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 6\
**Last updated:** [June 4, 2017, 9:21pm UTC](https://discourse.julialang.org/t/how-do-you-make-anonymous-module-w-variables/4068 "2017-06-04T21:21:55Z")

</div>

Doing some real hacky stuff. I want to make an anonymous module with variables. Kind of pseudocode, I want: module () foo = 404 end Where I’m at (in real code) is: cur\_anon = Module() // this returns: anonymous …

---

## [Invalid redefinition of constant?](https://discourse.julialang.org/t/invalid-redefinition-of-constant/4080)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 1\
**Last updated:** [June 4, 2017, 4:00pm UTC](https://discourse.julialang.org/t/invalid-redefinition-of-constant/4080 "2017-06-04T16:00:00Z")

</div>

I had somehow made a mental note, that is now possible: \_ \_ \_(\_)\_ | A fresh approach to technical computing (\_) | (\_) (\_) | Documentation: https://docs.julialang.org \_ \_ \_| |\_ \_\_ \_ | Typ…

---

## [Updating a package to support new version of Julia](https://discourse.julialang.org/t/updating-a-package-to-support-new-version-of-julia/2541)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 3\
**Last updated:** [March 9, 2017, 5:47pm UTC](https://discourse.julialang.org/t/updating-a-package-to-support-new-version-of-julia/2541 "2017-03-09T17:47:58Z")

</div>

I am interested in learning best practices and people’s experiences with updating a package to support a new version of Julia. I have written a few packages which all support julia v0.5, and will soon start the work of u…

---

## [How to trick Array{T} into behaving covariantly?](https://discourse.julialang.org/t/how-to-trick-array-t-into-behaving-covariantly/4071)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 13\
**Last updated:** [June 3, 2017, 4:53pm UTC](https://discourse.julialang.org/t/how-to-trick-array-t-into-behaving-covariantly/4071 "2017-06-03T16:53:16Z")

</div>

I am currently stuck trying to get the benefits of mutable lists while maintaining type covariance logic. Essentially I would like to be able to do the following: abstract VTKData typealias VTKDataGroup{T} Array{T\<:VTK…

---

## [Optional args and the methods they imply](https://discourse.julialang.org/t/optional-args-and-the-methods-they-imply/4062)

<div class="topic-metadata">

**Author:** [@hpoit](https://discourse.julialang.org/u/hpoit)\
**Replies:** 14\
**Last updated:** [June 2, 2017, 7:00pm UTC](https://discourse.julialang.org/t/optional-args-and-the-methods-they-imply/4062 "2017-06-02T19:00:08Z")

</div>

\# https://docs.julialang.org/en/stable/manual/methods/#man-note-on-optional-and-keyword-arguments # Optional args are implemented as syntax for multiple method definitions, e.g. f(a=1,b=2) = a+2b # which translates int…

---

## [Embedding Jullia, jl\_init(), julia\_init() and JULIA\_HOME](https://discourse.julialang.org/t/embedding-jullia-jl-init-julia-init-and-julia-home/4032)

<div class="topic-metadata">

**Author:** [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Replies:** 6\
**Last updated:** [June 2, 2017, 4:11pm UTC](https://discourse.julialang.org/t/embedding-jullia-jl-init-julia-init-and-julia-home/4032 "2017-06-02T16:11:24Z")

</div>

I need a bit of help from the experts. I’m continuing Joosep Pata’s work on ROOT.jl, a package that makes it possible to use CERN ROOT from Julia (via Cxx.jl). Cxx.jl alone is not enough, however, because ROOT-6 brings i…

---

## [How to specify the format in writedlm?](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058)

<div class="topic-metadata">

**Author:** [@jmo](https://discourse.julialang.org/u/jmo)\
**Replies:** 2\
**Last updated:** [June 2, 2017, 3:55pm UTC](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058 "2017-06-02T15:55:01Z")

</div>

Hi, I’m trying to write an array to a text file using writedlm. The array contains small floating point numbers but Julia saves it in a very odd format. Can I specify the format to e.g. “%g”? My problem can be illustr…

---

## [Writedlm works in REPL but not in a script](https://discourse.julialang.org/t/writedlm-works-in-repl-but-not-in-a-script/4061)

<div class="topic-metadata">

**Author:** [@phillefjonk](https://discourse.julialang.org/u/phillefjonk)\
**Replies:** 1\
**Last updated:** [June 2, 2017, 3:53pm UTC](https://discourse.julialang.org/t/writedlm-works-in-repl-but-not-in-a-script/4061 "2017-06-02T15:53:20Z")

</div>

Why does the following work in REPL julia\> A = rand(3,3) 3×3 Array{Float64,2}: 0.967353 0.187512 0.296005 0.616798 0.620456 0.076472 0.0759498 0.105753 0.41141 julia\> writedlm("data2.txt", A) julia\> But n…

---

## [How do I read a file with space separated values to become a matrix in Julia?](https://discourse.julialang.org/t/how-do-i-read-a-file-with-space-separated-values-to-become-a-matrix-in-julia/4056)

<div class="topic-metadata">

**Author:** [@phillefjonk](https://discourse.julialang.org/u/phillefjonk)\
**Replies:** 1\
**Last updated:** [June 2, 2017, 2:14pm UTC](https://discourse.julialang.org/t/how-do-i-read-a-file-with-space-separated-values-to-become-a-matrix-in-julia/4056 "2017-06-02T14:14:25Z")

</div>

I am having problems with types. I have a text file with three space separated rows with three floats numerical values in each row. Each row ends with CR. How do I read this file into a 3x3 matrix, holding numerical va…

---

## [Macro to create different sets of variables depending on the type of the macro argument](https://discourse.julialang.org/t/macro-to-create-different-sets-of-variables-depending-on-the-type-of-the-macro-argument/4037)

<div class="topic-metadata">

**Author:** [@bastikr](https://discourse.julialang.org/u/bastikr)\
**Replies:** 11\
**Last updated:** [June 2, 2017, 2:10pm UTC](https://discourse.julialang.org/t/macro-to-create-different-sets-of-variables-depending-on-the-type-of-the-macro-argument/4037 "2017-06-02T14:10:26Z")

</div>

Probably the easiest way to explain what I want to achieve is to give a simple example: x = 1 @def x should be the same as x = 1 a = sin(x) b = cos(x) But if x has a different type I want to define a different set o…

---

## [Do I need @async?](https://discourse.julialang.org/t/do-i-need-async/3993)

<div class="topic-metadata">

**Author:** [@pyrex41](https://discourse.julialang.org/u/pyrex41)\
**Replies:** 2\
**Last updated:** [June 2, 2017, 12:16pm UTC](https://discourse.julialang.org/t/do-i-need-async/3993 "2017-06-02T12:16:50Z")

</div>

I am working on a some simple helper functions to make simple backtesting very easy in julia. I am extending the ReactiveBasics packge. Here is some code for an example using a simple moving average crossover: using Rea…

---

## [Dict keys equality](https://discourse.julialang.org/t/dict-keys-equality/3986)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 17\
**Last updated:** [June 2, 2017, 8:42am UTC](https://discourse.julialang.org/t/dict-keys-equality/3986 "2017-06-02T08:42:02Z")

</div>

Why are the keys of Dict not equal? Why do I need to actually collect them? julia\> a = Dict(Symbol(i) =\> i for i = 1:5) Dict{Symbol,Int64} with 5 entries: Symbol("1") =\> 1 Symbol("2") =\> 2 Symbol("4") =\> 4 Symbo…

---

## [Groupedbar groups](https://discourse.julialang.org/t/groupedbar-groups/4043)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 2\
**Last updated:** [June 2, 2017, 8:00am UTC](https://discourse.julialang.org/t/groupedbar-groups/4043 "2017-06-02T08:00:20Z")

</div>

How do I denote the group names (or labels) in groupedbar? Right now it just outputs y1, y2, etc…

---

## [Is there native function for cpad (center version of lpad/rpad)?](https://discourse.julialang.org/t/is-there-native-function-for-cpad-center-version-of-lpad-rpad/4045)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 6\
**Last updated:** [June 2, 2017, 4:28am UTC](https://discourse.julialang.org/t/is-there-native-function-for-cpad-center-version-of-lpad-rpad/4045 "2017-06-02T04:28:22Z")

</div>

Is there a function in the native library to pad a string with ~equal spaces on both sides? cpad("woof", 8) would yield: " woof "

---

## [Does FFTW keep a system wisdom](https://discourse.julialang.org/t/does-fftw-keep-a-system-wisdom/4048)

<div class="topic-metadata">

**Author:** [@favba](https://discourse.julialang.org/u/favba)\
**Replies:** 2\
**Last updated:** [June 2, 2017, 4:24am UTC](https://discourse.julialang.org/t/does-fftw-keep-a-system-wisdom/4048 "2017-06-02T04:24:37Z")

</div>

Does a Julia’s FFTW library keeps its own system wisdom? I use fft’s quite often for a given set of array dimensions. I’d like to create optimized plans (using FFTW.EXHAUSTIVE flag). I know how to export and import plan…

---

## [The zero-argument anonymous function name](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025)

<div class="topic-metadata">

**Author:** [@hpoit](https://discourse.julialang.org/u/hpoit)\
**Replies:** 27\
**Last updated:** [June 1, 2017, 11:28pm UTC](https://discourse.julialang.org/t/the-zero-argument-anonymous-function-name/4025 "2017-06-01T23:28:52Z")

</div>

julia\> bar(a,b,x...) = (a,b,x) bar (generic function with 1 method) julia\> bar(1,2) (1,2,()) Is () a zero-argument anonymous function that takes in varargs, making zero really mean any-argument anonymous function? If y…

---

## [How do I get Julia to treat all elements of matrices as "floats" (like C type float)](https://discourse.julialang.org/t/how-do-i-get-julia-to-treat-all-elements-of-matrices-as-floats-like-c-type-float/4044)

<div class="topic-metadata">

**Author:** [@phillefjonk](https://discourse.julialang.org/u/phillefjonk)\
**Replies:** 2\
**Last updated:** [June 1, 2017, 8:36pm UTC](https://discourse.julialang.org/t/how-do-i-get-julia-to-treat-all-elements-of-matrices-as-floats-like-c-type-float/4044 "2017-06-01T20:36:39Z")

</div>

I have code that typically looks like the one below. How do I get Julia to treat all matrix entries and consecutive algebra as “floats”, like in C declaration; float A (as opposed to “double” or any other type) # Pseud…

---

## [One-liner definition of generated functions with where syntax](https://discourse.julialang.org/t/one-liner-definition-of-generated-functions-with-where-syntax/3982)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 0\
**Last updated:** [May 29, 2017, 10:29pm UTC](https://discourse.julialang.org/t/one-liner-definition-of-generated-functions-with-where-syntax/3982 "2017-05-29T22:29:33Z")

</div>

Is there a particular reason why the first definition doesn’t work? julia\> @generated foo(x::T) where T = x ERROR: invalid syntax; @generated must be used with a function definition julia\> @generated foo(x::T where T) …

---

## [How do I kill a spawned process?](https://discourse.julialang.org/t/how-do-i-kill-a-spawned-process/3824)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 9\
**Last updated:** [June 1, 2017, 5:04pm UTC](https://discourse.julialang.org/t/how-do-i-kill-a-spawned-process/3824 "2017-06-01T17:04:50Z")

</div>

Say I opened a video like this: f = "path2video.file" cmd = is\_windows() ? \`start $f\` : is\_linux() ? \`xdg-open $f\` : is\_apple() ? \`open $f\` : error("Unknown OS") run(cmd) How can I kill this process from within Julia l…

---

## [Convert a slice of BitArray to decimal](https://discourse.julialang.org/t/convert-a-slice-of-bitarray-to-decimal/4036)

<div class="topic-metadata">

**Author:** [@novatena](https://discourse.julialang.org/u/novatena)\
**Replies:** 1\
**Last updated:** [June 1, 2017, 3:09pm UTC](https://discourse.julialang.org/t/convert-a-slice-of-bitarray-to-decimal/4036 "2017-06-01T15:09:57Z")

</div>

I am writing a function which process a BitVector of length N. Each time, it processes a chunk of k bits (k is often between 1 and 20). Basically, I need to compute the hamming hamming distance of this chunk of bits with…

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

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