# General Usage

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

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

**Page:** 1061

---

## [Julia's equivalent to Fortran elemental functions](https://discourse.julialang.org/t/julias-equivalent-to-fortran-elemental-functions/2576)

<div class="topic-metadata">

**Author:** [@PieterjanRobbe](https://discourse.julialang.org/u/PieterjanRobbe)\
**Replies:** 3\
**Last updated:** [March 9, 2017, 8:50pm UTC](https://discourse.julialang.org/t/julias-equivalent-to-fortran-elemental-functions/2576 "2017-03-09T20:50:43Z")

</div>

Fortran has elemental functions. This means that you can define a function for primitive types (int, double…) and they will automatically work for vectors and matrices that contain these primitive types. Consider the e…

---

## [How to define a Julia function from C?](https://discourse.julialang.org/t/how-to-define-a-julia-function-from-c/2566)

<div class="topic-metadata">

**Author:** [@izaid](https://discourse.julialang.org/u/izaid)\
**Replies:** 8\
**Last updated:** [March 9, 2017, 7:49pm UTC](https://discourse.julialang.org/t/how-to-define-a-julia-function-from-c/2566 "2017-03-09T19:49:53Z")

</div>

Hi all, I’m a bit new to the Julia community, coming more from the Python / NumPy space. I’ve been using Julia internally for a while, and have spun part of my work out into a open-source package I hope to announce soon…

---

## [Getting the base type in 0.6](https://discourse.julialang.org/t/getting-the-base-type-in-0-6/2425)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 6\
**Last updated:** [March 9, 2017, 4:12pm UTC](https://discourse.julialang.org/t/getting-the-base-type-in-0-6/2425 "2017-03-09T16:12:28Z")

</div>

Given t = SomeType{Int64}, we used to be able to get SomeType via t.name.primary. That no longer works in 0.6. How should I do that? t.name still exists, but it’s a TypeName. Alternatively, all I really want is, given a…

---

## [Inspecting closures](https://discourse.julialang.org/t/inspecting-closures/2397)

<div class="topic-metadata">

**Author:** [@zabolekar](https://discourse.julialang.org/u/zabolekar)\
**Replies:** 11\
**Last updated:** [March 8, 2017, 11:31pm UTC](https://discourse.julialang.org/t/inspecting-closures/2397 "2017-03-08T23:31:32Z")

</div>

Is there a way to inspect and modify the environment of a function, like environment in R or the (admittedly ugly, but working) combination of .\_\_code\_\_.co\_freevars, .\_\_closure\_\_\[idx\].cell\_contents and ctypes.pythonapi.…

---

## [Nested (non-syntactic?) loop fusion in 0.6](https://discourse.julialang.org/t/nested-non-syntactic-loop-fusion-in-0-6/2544)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 4\
**Last updated:** [March 8, 2017, 6:20pm UTC](https://discourse.julialang.org/t/nested-non-syntactic-loop-fusion-in-0-6/2544 "2017-03-08T18:20:52Z")

</div>

Is there a way for loop fusion in Julia to operate even recursively into function calls? By that I mean, consider, julia\> a=b=rand(2000,2000); julia\> @time a.+b.+a; 0.064173 seconds (10.63 k allocations: 31.015 MiB, …

---

## [Is this expected behavior (0.5 to 0.6 breakage)?](https://discourse.julialang.org/t/is-this-expected-behavior-0-5-to-0-6-breakage/2534)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 9\
**Last updated:** [March 8, 2017, 3:17pm UTC](https://discourse.julialang.org/t/is-this-expected-behavior-0-5-to-0-6-breakage/2534 "2017-03-08T15:17:10Z")

</div>

In 0.5: julia\> a = Vector{UInt32}(\[0x01, 0x02, 0x03\]) 3-element Array{UInt32,1}: 0x00000001 0x00000002 0x00000003 julia\> a + 1 3-element Array{UInt32,1}: 0x00000002 0x00000003 0x00000004 In 0.6: julia\> a = Vect…

---

## [Conventions for finalizers, resources, and cleanup](https://discourse.julialang.org/t/conventions-for-finalizers-resources-and-cleanup/1693)

<div class="topic-metadata">

**Author:** [@adambrewster](https://discourse.julialang.org/u/adambrewster)\
**Replies:** 1\
**Last updated:** [March 8, 2017, 4:27am UTC](https://discourse.julialang.org/t/conventions-for-finalizers-resources-and-cleanup/1693 "2017-03-08T04:27:26Z")

</div>

I posted something similar in response to issue #7721, but that may be buried forever, so I’ll ask again here. I went looking for the community’s current position on finalizers and resource cleanup, and I found a couple…

---

## [Question about NLopt](https://discourse.julialang.org/t/question-about-nlopt/2013)

<div class="topic-metadata">

**Author:** [@arinbasu](https://discourse.julialang.org/u/arinbasu)\
**Replies:** 6\
**Last updated:** [March 8, 2017, 3:52am UTC](https://discourse.julialang.org/t/question-about-nlopt/2013 "2017-03-08T03:52:31Z")

</div>

Hi All, (A friend asks): I have a task that I think the MixedModels package may be better able to handle than lme4 in R. I did a clean Julia install before proceeding to install MixedModels. Unfortunately the current …

---

## [Juno error: Error loading Atom.jl package](https://discourse.julialang.org/t/juno-error-error-loading-atom-jl-package/2509)

<div class="topic-metadata">

**Author:** [@ilanggear](https://discourse.julialang.org/u/ilanggear)\
**Replies:** 7\
**Last updated:** [March 8, 2017, 1:14am UTC](https://discourse.julialang.org/t/juno-error-error-loading-atom-jl-package/2509 "2017-03-08T01:14:59Z")

</div>

When I selected a few lines of code and then selected Julia → Run Block, I get the following error message: “Go to the Packages → Julia → Open Terminal menu and run Pkg.update()in Julia, then try again. If you still se…

---

## [Misleading error message in Primes](https://discourse.julialang.org/t/misleading-error-message-in-primes/2531)

<div class="topic-metadata">

**Author:** [@leiteiro](https://discourse.julialang.org/u/leiteiro)\
**Replies:** 1\
**Last updated:** [March 7, 2017, 10:50pm UTC](https://discourse.julialang.org/t/misleading-error-message-in-primes/2531 "2017-03-07T22:50:32Z")

</div>

On my system N = Int64(2)^30 primes(N) works fine. However N = BigInt(2)^30 primes(N) throws LoadError: primes(1073741824,) has been moved to the package Primes.jl. Run Pkg.add("Primes") to install Primes on Julia v…

---

## [Update Copr RPM repository for Julia 0.5.1](https://discourse.julialang.org/t/update-copr-rpm-repository-for-julia-0-5-1/2530)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 3\
**Last updated:** [March 7, 2017, 9:23pm UTC](https://discourse.julialang.org/t/update-copr-rpm-repository-for-julia-0-5-1/2530 "2017-03-07T21:23:08Z")

</div>

Will the Copr repository for Fedora be updated with this version of Julia?

---

## [Does Julia use SIMD instructions for broadcast operations?](https://discourse.julialang.org/t/does-julia-use-simd-instructions-for-broadcast-operations/2492)

<div class="topic-metadata">

**Author:** [@mcovalt](https://discourse.julialang.org/u/mcovalt)\
**Replies:** 18\
**Last updated:** [March 7, 2017, 8:19pm UTC](https://discourse.julialang.org/t/does-julia-use-simd-instructions-for-broadcast-operations/2492 "2017-03-07T20:19:04Z")

</div>

I see @simd can be used to vectorize for loops. How about for broadcast()? Will broadcast(f,A) translate to SIMD instructions of f operating on the elements A? Will multiple instances of f be sent to multiple threads?

---

## [Build error on Travis and appveyor - basemap python](https://discourse.julialang.org/t/build-error-on-travis-and-appveyor-basemap-python/2520)

<div class="topic-metadata">

**Author:** [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Replies:** 1\
**Last updated:** [March 7, 2017, 8:06pm UTC](https://discourse.julialang.org/t/build-error-on-travis-and-appveyor-basemap-python/2520 "2017-03-07T20:06:35Z")

</div>

Hello, I have some build error on Travis ans Appveyor related to the use of basemap in my package. Build error on appveyor ERROR: LoadError: LoadError: PyError (:PyImport\_ImportModule) \<type 'exceptions.ImportError'\> …

---

## [Implementing non-stateful iteration](https://discourse.julialang.org/t/implementing-non-stateful-iteration/2525)

<div class="topic-metadata">

**Author:** [@malmaud](https://discourse.julialang.org/u/malmaud)\
**Replies:** 5\
**Last updated:** [March 7, 2017, 7:27pm UTC](https://discourse.julialang.org/t/implementing-non-stateful-iteration/2525 "2017-03-07T19:27:37Z")

</div>

I’m trying to wrap a C library where iteration is intrinsically non-stateful, as shown below. void \*y = ...; void \*x = start\_iteration(y); while (x!=NULL) { do\_something(x); x = get\_next(y); } I was wondering if an…

---

## [Can I define a precompile sequence?](https://discourse.julialang.org/t/can-i-define-a-precompile-sequence/2474)

<div class="topic-metadata">

**Author:** [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Replies:** 3\
**Last updated:** [March 7, 2017, 3:03pm UTC](https://discourse.julialang.org/t/can-i-define-a-precompile-sequence/2474 "2017-03-07T15:03:04Z")

</div>

I find it a bit difficult to figure out how to use the precompile system properly. Documentation appears to be sparse. A few months ago @tim.holy made an interesting post on my Github page: → https://github.com/ma-la…

---

## [Fast String processing in Julia vs. Python](https://discourse.julialang.org/t/fast-string-processing-in-julia-vs-python/2443)

<div class="topic-metadata">

**Author:** [@mbeltagy](https://discourse.julialang.org/u/mbeltagy)\
**Replies:** 37\
**Last updated:** [March 7, 2017, 2:51pm UTC](https://discourse.julialang.org/t/fast-string-processing-in-julia-vs-python/2443 "2017-03-07T14:51:26Z")

</div>

I am trying to convert this notebook on probability by Peter Norvig. I observe that Python runs much faster than Julia. I couldn’t pin down the problem in my Julia code. What is happening here is that we are looping ove…

---

## [Why is there type instability in this function?](https://discourse.julialang.org/t/why-is-there-type-instability-in-this-function/2508)

<div class="topic-metadata">

**Author:** [@Sean\_McBane](https://discourse.julialang.org/u/Sean_McBane)\
**Replies:** 5\
**Last updated:** [March 7, 2017, 12:47am UTC](https://discourse.julialang.org/t/why-is-there-type-instability-in-this-function/2508 "2017-03-07T00:47:36Z")

</div>

I have the following toy function implementing a backward difference formula (homework): function newton\_iteration{T}(x0::T, F, J; tol=2\*eps(), testfun=norm)::T x = x0 - J(x0) \\ F(x0) while testfun(x) \> tol …

---

## [Installing julia on Ubuntu 16.04 VM](https://discourse.julialang.org/t/installing-julia-on-ubuntu-16-04-vm/2491)

<div class="topic-metadata">

**Author:** [@Pierre-Louis\_Poirion](https://discourse.julialang.org/u/Pierre-Louis_Poirion)\
**Replies:** 6\
**Last updated:** [March 6, 2017, 1:39pm UTC](https://discourse.julialang.org/t/installing-julia-on-ubuntu-16-04-vm/2491 "2017-03-06T13:39:55Z")

</div>

Hello I am having trouble to install/update any package on julia 0.6 for example Pkg.update() leads to the following error julia\> Pkg.update() INFO: Initializing package repository /root/.julia/v0.6 ERROR: ReadOnlyMe…

---

## [Sample() from a data vector with NA values](https://discourse.julialang.org/t/sample-from-a-data-vector-with-na-values/2482)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 4\
**Last updated:** [March 6, 2017, 1:31pm UTC](https://discourse.julialang.org/t/sample-from-a-data-vector-with-na-values/2482 "2017-03-06T13:31:11Z")

</div>

Is there a way to use sample() function from a DataArray in a way that deals gracefully with NA values? What I mean is that if I do sample(a), it works fine - sometimes returning a Float64, and sometimes returning NA. B…

---

## [How to use relation "many-to-many" with hashing ? like Dict](https://discourse.julialang.org/t/how-to-use-relation-many-to-many-with-hashing-like-dict/2431)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 4\
**Last updated:** [March 6, 2017, 8:34am UTC](https://discourse.julialang.org/t/how-to-use-relation-many-to-many-with-hashing-like-dict/2431 "2017-03-06T08:34:10Z")

</div>

I need fast searching for relation many-to-many julia\> a=\[1 1 1 2 2 3\]’ 6×1 Array{Int64,2}: 1 1 1 2 2 3 julia\> b=\[100 100 200 300 300 500\]’ 6×1 Array{Int64,2}: 100 100 200 300 300 500 julia\> Dict(zip(a,b…

---

## [HDF5 Error](https://discourse.julialang.org/t/hdf5-error/2484)

<div class="topic-metadata">

**Author:** [@aholmesie](https://discourse.julialang.org/u/aholmesie)\
**Replies:** 1\
**Last updated:** [March 6, 2017, 4:41am UTC](https://discourse.julialang.org/t/hdf5-error/2484 "2017-03-06T04:41:42Z")

</div>

Hi, I just installed Julia via Atom and had a lot of issues but finally worked it out after reading a lot of suggestions here http://discuss.junolab.org/t/not-able-to-install-juno-via-atom/562/26. Now when I try to run m…

---

## [Strange behavior with Void?](https://discourse.julialang.org/t/strange-behavior-with-void/2480)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 2\
**Last updated:** [March 5, 2017, 10:51pm UTC](https://discourse.julialang.org/t/strange-behavior-with-void/2480 "2017-03-05T22:51:42Z")

</div>

Consider the following: \> a = Vector{Void}(100\_000\_000); \> b = Set(a); # note: this takes \> 1 second \> b.dict Dict{Void,Void} with 1 entry: nothing =\> nothing \> whos() ... a 0 bytes 100000000-element Array{Vo…

---

## [Macro parsing](https://discourse.julialang.org/t/macro-parsing/2473)

<div class="topic-metadata">

**Author:** [@ZacLN](https://discourse.julialang.org/u/ZacLN)\
**Replies:** 4\
**Last updated:** [March 5, 2017, 9:14pm UTC](https://discourse.julialang.org/t/macro-parsing/2473 "2017-03-05T21:14:11Z")

</div>

Is @Base.time sin(1) parsing and evaling as Base.@time sin(1) intended/expected behaviour?

---

## [Getting Unwanted Quotes in System Calls](https://discourse.julialang.org/t/getting-unwanted-quotes-in-system-calls/2451)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 1\
**Last updated:** [March 4, 2017, 11:52pm UTC](https://discourse.julialang.org/t/getting-unwanted-quotes-in-system-calls/2451 "2017-03-04T23:52:34Z")

</div>

file\_name = "$(Pkg.dir())/blah/blah.jl" file\_alias = "julia -L $file\_name -e 'main()' --" println(\`alias whatev=$file\_alias; meow hello\`) prints out: \`alias "whatev=julia -L /Users/dan/.julia/v0.5/blah/blah.jl -e 'ma…

---

## [Testing C functions with Julia](https://discourse.julialang.org/t/testing-c-functions-with-julia/2435)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 12\
**Last updated:** [March 4, 2017, 11:02pm UTC](https://discourse.julialang.org/t/testing-c-functions-with-julia/2435 "2017-03-04T23:02:43Z")

</div>

Hello, I want to use Julia to write unit tests for C functions. How can I do this? Example of a C function: #include "../include/mixer.h" void mixer(REAL32 total\_thrust, REAL32 delta\_thrust, struct actuator\_output \*…

---

## [Piping directly to STDIN](https://discourse.julialang.org/t/piping-directly-to-stdin/2446)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 5\
**Last updated:** [March 4, 2017, 10:26pm UTC](https://discourse.julialang.org/t/piping-directly-to-stdin/2446 "2017-03-04T22:26:29Z")

</div>

I’m writing an integration test and want to know the best way to pipe to STDIN. The closest I’ve gotten is print(STDIN, "blah"), but this still required me to press enter. What’s the best way to accomplish this? I kno…

---

## [Pkg broken: "No feasible version" error](https://discourse.julialang.org/t/pkg-broken-no-feasible-version-error/2347)

<div class="topic-metadata">

**Author:** [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Replies:** 16\
**Last updated:** [March 4, 2017, 9:21pm UTC](https://discourse.julialang.org/t/pkg-broken-no-feasible-version-error/2347 "2017-03-04T21:21:11Z")

</div>

I have a recurrent issue with Pkg, that means I cannot update packages. Pkg operations (add, rm, update) fail with: ERROR: unsatisfiable package requirements detected: no feasible version could be found for package: Qua…

---

## [Useful bug report without compiler?](https://discourse.julialang.org/t/useful-bug-report-without-compiler/2445)

<div class="topic-metadata">

**Author:** [@fratrik](https://discourse.julialang.org/u/fratrik)\
**Replies:** 3\
**Last updated:** [March 4, 2017, 5:02pm UTC](https://discourse.julialang.org/t/useful-bug-report-without-compiler/2445 "2017-03-04T17:02:20Z")

</div>

I am very much enjoying learning about Julia. However, I have run into a problem. When I try to profile my code, I end up with a Please submit a bug report with steps to reproduce this fault, and any error messages th…

---

## [Juno hangs when trying to inspect large objects in Workspace](https://discourse.julialang.org/t/juno-hangs-when-trying-to-inspect-large-objects-in-workspace/2444)

<div class="topic-metadata">

**Author:** [@MrJ](https://discourse.julialang.org/u/MrJ)\
**Replies:** 0\
**Last updated:** [March 4, 2017, 3:54pm UTC](https://discourse.julialang.org/t/juno-hangs-when-trying-to-inspect-large-objects-in-workspace/2444 "2017-03-04T15:54:22Z")

</div>

I’m storing a lot of string data in sets. These sets I store in fields of objects. Now I’m having the problem that when I click on the little arrow next to one of the objects in the Juno Workspace, the object does not e…

---

## [Performance regression of Cuba.jl on Julia 0.6](https://discourse.julialang.org/t/performance-regression-of-cuba-jl-on-julia-0-6/2424)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 13\
**Last updated:** [March 4, 2017, 3:50pm UTC](https://discourse.julialang.org/t/performance-regression-of-cuba-jl-on-julia-0-6/2424 "2017-03-04T15:50:32Z")

</div>

I noticed a performance regression of Cuba.jl on Julia 0.6, compared to Julia 0.5. It can be reproduced with these simple examples Julia 0.5: julia\> using Cuba, BenchmarkTools julia\> @benchmark cuhre((x,f) -\> f\[1\] = …

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

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