# General Usage

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

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

**Page:** 762

---

## [Is there a dictionary-based data structure where the keys are disjoint ranges, and indexing with an integer looks up the matching range?](https://discourse.julialang.org/t/is-there-a-dictionary-based-data-structure-where-the-keys-are-disjoint-ranges-and-indexing-with-an-integer-looks-up-the-matching-range/38125)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [April 24, 2020, 7:30am UTC](https://discourse.julialang.org/t/is-there-a-dictionary-based-data-structure-where-the-keys-are-disjoint-ranges-and-indexing-with-an-integer-looks-up-the-matching-range/38125 "2020-04-24T07:30:17Z")

</div>

For example, julia\> d = Dict(1:4=\>"abc",10:14=\>"def") Dict{UnitRange{Int64},String} with 2 entries: 10:14 =\> "def" 1:4 =\> "abc" # What I want julia\> d\[3\] "abc" julia\> d\[11\] "def" julia\> d\[5\] ERROR: KeyError: ke…

---

## [Difference between Type{T} and T when passing type variable inside generated function?](https://discourse.julialang.org/t/difference-between-type-t-and-t-when-passing-type-variable-inside-generated-function/38121)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 5\
**Last updated:** [April 24, 2020, 3:29am UTC](https://discourse.julialang.org/t/difference-between-type-t-and-t-when-passing-type-variable-inside-generated-function/38121 "2020-04-24T03:29:25Z")

</div>

Why passing type argument into @generated function changes its value from T into Type{T}? function type\_print(T) return :(println($T)) end macro type\_print(T) return :(println($T)) end @generated function type\_pri…

---

## [Generate faa di bruno matrix](https://discourse.julialang.org/t/generate-faa-di-bruno-matrix/38059)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 9\
**Last updated:** [April 24, 2020, 2:25am UTC](https://discourse.julialang.org/t/generate-faa-di-bruno-matrix/38059 "2020-04-24T02:25:31Z")

</div>

I am trying to implement the funcion A(x1, x2, x3, ..xn) Such that \[A\]\_{m,j} = B\_{m,j} , where B\_{m,j} corresponds to the incomplete bell polynomial. The thing is, that I don’t want to have to construct that matrix ev…

---

## [Is there a difference under the hood between running code via a .jl file and running code via \`test name\_of\_pkg\`?](https://discourse.julialang.org/t/is-there-a-difference-under-the-hood-between-running-code-via-a-jl-file-and-running-code-via-test-name-of-pkg/38097)

<div class="topic-metadata">

**Author:** [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Replies:** 4\
**Last updated:** [April 24, 2020, 12:28am UTC](https://discourse.julialang.org/t/is-there-a-difference-under-the-hood-between-running-code-via-a-jl-file-and-running-code-via-test-name-of-pkg/38097 "2020-04-24T00:28:19Z")

</div>

Hey all, I am running into a weird issue. I have some code which I will arbitrarily say is: function z() z = 10 z += 100 end z() # This code will work, it's just an arbitrary example. When I have the above code…

---

## [Unexpected ")"](https://discourse.julialang.org/t/unexpected/38115)

<div class="topic-metadata">

**Author:** [@MJMB](https://discourse.julialang.org/u/MJMB)\
**Replies:** 3\
**Last updated:** [April 24, 2020, 12:14am UTC](https://discourse.julialang.org/t/unexpected/38115 "2020-04-24T00:14:27Z")

</div>

@constraint(Mod, Load\[t\], sum(P\[f, t\] for fin F, for t in T))==Demand(t) I got an error for that showing unexpected")" Can i get more explanation about the error

---

## [Why some operator symbols aren't allowed?](https://discourse.julialang.org/t/why-some-operator-symbols-arent-allowed/38104)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 4\
**Last updated:** [April 23, 2020, 11:16pm UTC](https://discourse.julialang.org/t/why-some-operator-symbols-arent-allowed/38104 "2020-04-23T23:16:17Z")

</div>

Hello, Why some symbols aren’t allowed to create new operators? julia\> →(a, b) = a + b julia\> 1 → 2 3 julia\> ∠(a, b) = a + b julia\> 1 ∠ 2 ERROR: syntax: extra token "∠" after end of expression Stacktrace: \[1\] top-lev…

---

## [Appending to a multidimensional array](https://discourse.julialang.org/t/appending-to-a-multidimensional-array/8425)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 7\
**Last updated:** [April 23, 2020, 8:21pm UTC](https://discourse.julialang.org/t/appending-to-a-multidimensional-array/8425 "2020-04-23T20:21:30Z")

</div>

So I am generating a sequence of Nxd arrays, which are trajectories in d-diemsnional space. I would like to append them to one another. In the case d=1, I can do this with append! Is there a generalization to the d-di…

---

## [DataFrame vs. Pandas (vs. Excel...), e.g. to refer to previous row](https://discourse.julialang.org/t/dataframe-vs-pandas-vs-excel-e-g-to-refer-to-previous-row/38094)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 6\
**Last updated:** [April 23, 2020, 7:30pm UTC](https://discourse.julialang.org/t/dataframe-vs-pandas-vs-excel-e-g-to-refer-to-previous-row/38094 "2020-04-23T19:30:03Z")

</div>

Hi, A. Is there any tutorial to not just DataFrames, but the whole ecosystem around it, e.g. for those coming from Python/Pandas? Or maybe just some cheatsheet? B. I have a specific problem, in Excel it’s simple to …

---

## [How do I plot the estimated cumulative density function of some samples?](https://discourse.julialang.org/t/how-do-i-plot-the-estimated-cumulative-density-function-of-some-samples/38032)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 6\
**Last updated:** [April 23, 2020, 5:03pm UTC](https://discourse.julialang.org/t/how-do-i-plot-the-estimated-cumulative-density-function-of-some-samples/38032 "2020-04-23T17:03:30Z")

</div>

I have some samples of a random variable, and I want to plot their cdf. What’s the best way to do this? I have currently tried: g1 = \[E(λ) for i = 1:n\] # generate the samples using StatsBase cdf = ecdf(g1) …

---

## [Error optimizing using autodifferentation](https://discourse.julialang.org/t/error-optimizing-using-autodifferentation/35478)

<div class="topic-metadata">

**Author:** [@rpm](https://discourse.julialang.org/u/rpm)\
**Replies:** 7\
**Last updated:** [April 23, 2020, 4:42pm UTC](https://discourse.julialang.org/t/error-optimizing-using-autodifferentation/35478 "2020-04-23T16:42:05Z")

</div>

I am a new Julia user working with the Optim package and trying to estimate a model (minimizing the sum of squared residuals), but receive an error (I read the PSA on posting–let me know if I could do any better in regar…

---

## [How can i Decode this Data?](https://discourse.julialang.org/t/how-can-i-decode-this-data/38084)

<div class="topic-metadata">

**Author:** [@imrankhan\_juliaLang](https://discourse.julialang.org/u/imrankhan_juliaLang)\
**Replies:** 2\
**Last updated:** [April 23, 2020, 3:32pm UTC](https://discourse.julialang.org/t/how-can-i-decode-this-data/38084 "2020-04-23T15:32:31Z")

</div>

How can i convert this data to numeric.

---

## [ERROR: UndefVarError: T not defined / Weird Method Parameter Problem](https://discourse.julialang.org/t/error-undefvarerror-t-not-defined-weird-method-parameter-problem/32427)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [April 23, 2020, 7:46am UTC](https://discourse.julialang.org/t/error-undefvarerror-t-not-defined-weird-method-parameter-problem/32427 "2020-04-23T07:46:12Z")

</div>

abstract type Fun{T,R} \<: Function end struct TypedFun{T\<:Tuple,R} \<: Fun{T,R} fn::Function end function test(fun::Fun{Tuple{T},Vector{CV} where CV\<:T}) where T println(T) end function testy(fun::Fun{Tuple{T}…

---

## [Unexpected Core.Box from functions within a function](https://discourse.julialang.org/t/unexpected-core-box-from-functions-within-a-function/38022)

<div class="topic-metadata">

**Author:** [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Replies:** 4\
**Last updated:** [April 23, 2020, 6:34am UTC](https://discourse.julialang.org/t/unexpected-core-box-from-functions-within-a-function/38022 "2020-04-23T06:34:14Z")

</div>

I was surprised that something like the following is slow, and not type-stable: function g(A) function make(A) B = similar(A) act!(B, A, axes(A, 1)) B end function act!(B, A, ax) …

---

## [Training Halts when Using CuArrarys](https://discourse.julialang.org/t/training-halts-when-using-cuarrarys/38062)

<div class="topic-metadata">

**Author:** [@lpjiang97](https://discourse.julialang.org/u/lpjiang97)\
**Replies:** 0\
**Last updated:** [April 23, 2020, 4:40am UTC](https://discourse.julialang.org/t/training-halts-when-using-cuarrarys/38062 "2020-04-23T04:40:35Z")

</div>

(open issue here) I’m fairly new to CuArrays and Flux, and I met this problem of having halted training after some epochs. There is no CUDA out of memory error, but the usage is extremely high for this simple linear mod…

---

## [Testing whether value is (or not) in array](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995)

<div class="topic-metadata">

**Author:** [@EricChameroy](https://discourse.julialang.org/u/EricChameroy)\
**Replies:** 4\
**Last updated:** [April 23, 2020, 1:30am UTC](https://discourse.julialang.org/t/testing-whether-value-is-or-not-in-array/37995 "2020-04-23T01:30:46Z")

</div>

Hi everyone, I understand that if I want to test if a given value is present in an array, I can use: value in array However, how do I go about testing if a given value is not in an array? So far, the only solution I c…

---

## [Exporting a surface](https://discourse.julialang.org/t/exporting-a-surface/38040)

<div class="topic-metadata">

**Author:** [@Bigorneau](https://discourse.julialang.org/u/Bigorneau)\
**Replies:** 4\
**Last updated:** [April 22, 2020, 9:21pm UTC](https://discourse.julialang.org/t/exporting-a-surface/38040 "2020-04-22T21:21:34Z")

</div>

Hi, I could not find any resources online about exporting a surface as a mesh in Julia. To be more precise, suppose at the end of some computation I have a surface only known as the three matrices X,Y,Z. I can visualize…

---

## [Creating \*.dll with packageCompiler](https://discourse.julialang.org/t/creating-dll-with-packagecompiler/37811)

<div class="topic-metadata">

**Author:** [@Owolf](https://discourse.julialang.org/u/Owolf)\
**Replies:** 2\
**Last updated:** [April 22, 2020, 7:13pm UTC](https://discourse.julialang.org/t/creating-dll-with-packagecompiler/37811 "2020-04-22T19:13:54Z")

</div>

Hello, I would like to create \*.dll file from my \*.jl code. Before I had packageCompiler version 0.6.4 and it works just perfectly. I only did something like this: using PackageCompiler build\_shared\_lib("test.jl", "te…

---

## [Efficiently Store and Access Large 3-Dimensional Arrays](https://discourse.julialang.org/t/efficiently-store-and-access-large-3-dimensional-arrays/37656)

<div class="topic-metadata">

**Author:** [@Dr.Merkwuedigliebe](https://discourse.julialang.org/u/Dr.Merkwuedigliebe)\
**Replies:** 12\
**Last updated:** [April 22, 2020, 5:19pm UTC](https://discourse.julialang.org/t/efficiently-store-and-access-large-3-dimensional-arrays/37656 "2020-04-22T17:19:19Z")

</div>

I am working on a simulation that stores and remove values (some form of float) at various points in a 3-dimensional space, represented by an array with a size of ~(2e4 x 4e4 x 1e2). Specifically, it records the property…

---

## [My my factorial functions return 1 for any negative value](https://discourse.julialang.org/t/my-my-factorial-functions-return-1-for-any-negative-value/38035)

<div class="topic-metadata">

**Author:** [@A.U.M](https://discourse.julialang.org/u/A.U.M)\
**Replies:** 1\
**Last updated:** [April 22, 2020, 4:58pm UTC](https://discourse.julialang.org/t/my-my-factorial-functions-return-1-for-any-negative-value/38035 "2020-04-22T16:58:36Z")

</div>

Why my Factorial functions return 1 for any negative value always? my\_factorial(n::Integer)::BigInt = reduce(\*, BigInt(1):BigInt(n))

---

## [Creating an environment to use specific versions of packages, Julia uses most current anyway](https://discourse.julialang.org/t/creating-an-environment-to-use-specific-versions-of-packages-julia-uses-most-current-anyway/38021)

<div class="topic-metadata">

**Author:** [@cby](https://discourse.julialang.org/u/cby)\
**Replies:** 2\
**Last updated:** [April 22, 2020, 4:21pm UTC](https://discourse.julialang.org/t/creating-an-environment-to-use-specific-versions-of-packages-julia-uses-most-current-anyway/38021 "2020-04-22T16:21:15Z")

</div>

I am trying to create an environment as shown here to specifically use an older version of a package (JuMPv.19), which seems to be successful. (JuMPv.19) pkg\> st Status \`~/JuliaEnvs/JuMPv.19/Project.toml\` \[2e9cd046\] G…

---

## [Fastest way to compute \`A^n \* x\` for large matrices \`A\` and vector \`x\`](https://discourse.julialang.org/t/fastest-way-to-compute-a-n-x-for-large-matrices-a-and-vector-x/37900)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 13\
**Last updated:** [April 22, 2020, 3:54pm UTC](https://discourse.julialang.org/t/fastest-way-to-compute-a-n-x-for-large-matrices-a-and-vector-x/37900 "2020-04-22T15:54:25Z")

</div>

I have the following two (functionally equivalent) functions function mul1(A, xin) x1 = copy(xin) x2 = A\*x1 for i in 1:20 x2 = A\*x1 x1, x2 = x2, x1 end return x1 end and function mu…

---

## [Profiling allocations?](https://discourse.julialang.org/t/profiling-allocations/38016)

<div class="topic-metadata">

**Author:** [@angelv](https://discourse.julialang.org/u/angelv)\
**Replies:** 8\
**Last updated:** [April 22, 2020, 3:02pm UTC](https://discourse.julialang.org/t/profiling-allocations/38016 "2020-04-22T15:02:06Z")

</div>

Hello, I wrote a simple function recursively and when testing it I found that it allocates a lot of memory. julia\> @time brute\_force(10,63) \[...\] 32.055675 seconds (392.13 M allocations: 8.765 GiB, 28.16% gc time) I …

---

## [Using JuliaWebAPI.jl for simple REST API](https://discourse.julialang.org/t/using-juliawebapi-jl-for-simple-rest-api/38008)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 0\
**Last updated:** [April 22, 2020, 4:45am UTC](https://discourse.julialang.org/t/using-juliawebapi-jl-for-simple-rest-api/38008 "2020-04-22T04:45:42Z")

</div>

I want to expose a function on a remote server that processes some data and returns a CSV file to a non-Julia client. Performance isn’t critical, so I thought a simple HTTP interface would work well. From the descripti…

---

## [Returning symbolic variable from modeul](https://discourse.julialang.org/t/returning-symbolic-variable-from-modeul/38023)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 1\
**Last updated:** [April 22, 2020, 1:55pm UTC](https://discourse.julialang.org/t/returning-symbolic-variable-from-modeul/38023 "2020-04-22T13:55:05Z")

</div>

The following code works if you run it directly in REPL module MyM using SymPy export beta, return\_beta beta = symbols("β") function return\_beta() return -beta end end MyM.return\_beta() But if you put MyM in a file…

---

## [Tables DataFrames package conflict](https://discourse.julialang.org/t/tables-dataframes-package-conflict/38024)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 2\
**Last updated:** [April 22, 2020, 1:43pm UTC](https://discourse.julialang.org/t/tables-dataframes-package-conflict/38024 "2020-04-22T13:43:06Z")

</div>

When I tried to install the latest package version of MySQL (apparently revamped) I got a dependency failure due to a conflict between the package ‘Tables’ and ‘DataFrames’: ERROR: Unsatisfiable requirements detected fo…

---

## [How to convert CartesianIndex to integer](https://discourse.julialang.org/t/how-to-convert-cartesianindex-to-integer/38017)

<div class="topic-metadata">

**Author:** [@hmemy](https://discourse.julialang.org/u/hmemy)\
**Replies:** 2\
**Last updated:** [April 22, 2020, 9:30am UTC](https://discourse.julialang.org/t/how-to-convert-cartesianindex-to-integer/38017 "2020-04-22T09:30:54Z")

</div>

Hi, I am using findall function to create an array. but the results are in CartesianIndex as shown below. A = findall(x-\>x\>0, test) This results in 5-element Array{CartesianIndex{2},1}: CartesianIndex(1, 3) Cartesi…

---

## [Is is just me or](https://discourse.julialang.org/t/is-is-just-me-or/38003)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 0\
**Last updated:** [April 22, 2020, 2:41am UTC](https://discourse.julialang.org/t/is-is-just-me-or/38003 "2020-04-22T02:41:36Z")

</div>

…is 1.4 a lot snappier in a lot of ways. I am eyeballing and I time runs of something new I’m working on. Those timings are about 10% or more faster. I’ve improved the code a little, but I’ve also added some tricky fea…

---

## [How do I capture the output of @code\_llvm in a variable?](https://discourse.julialang.org/t/how-do-i-capture-the-output-of-code-llvm-in-a-variable/37994)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 2\
**Last updated:** [April 21, 2020, 11:55pm UTC](https://discourse.julialang.org/t/how-do-i-capture-the-output-of-code-llvm-in-a-variable/37994 "2020-04-21T23:55:12Z")

</div>

I want to capture it so I can open it in a pager: function more(content::AbstractString) run(pipeline(\`echo $(content)\`, \`less\`)) nothing end more(@code\_llvm sth())

---

## [Help to remove type instability](https://discourse.julialang.org/t/help-to-remove-type-instability/37988)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 5\
**Last updated:** [April 21, 2020, 7:48pm UTC](https://discourse.julialang.org/t/help-to-remove-type-instability/37988 "2020-04-21T19:48:29Z")

</div>

Hi! I am trying to create a signal system for my package TextUserInterfaces.jl. As of now, I have the following kind of structure defining a signal that will be emitted when return is pressed: mutable struct Object …

---

## [NamedTuples with constant type](https://discourse.julialang.org/t/namedtuples-with-constant-type/37977)

<div class="topic-metadata">

**Author:** [@Isaia\_Nisoli](https://discourse.julialang.org/u/Isaia_Nisoli)\
**Replies:** 2\
**Last updated:** [April 21, 2020, 6:43pm UTC](https://discourse.julialang.org/t/namedtuples-with-constant-type/37977 "2020-04-21T18:43:28Z")

</div>

Dear all, I’m defining a struct struct foo{S, T} val::NamedTuple{S} end where S is a tuple of Symbols and all the element of the NamedTuple are of type T. Essentially, if S=(:1, :2), what we are looking at is a …

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

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