# General Usage

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

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

**Page:** 913

---

## [Specify type of function](https://discourse.julialang.org/t/specify-type-of-function/18373)

<div class="topic-metadata">

**Author:** [@linuslagerhjelm](https://discourse.julialang.org/u/linuslagerhjelm)\
**Replies:** 2\
**Last updated:** [December 6, 2018, 12:54pm UTC](https://discourse.julialang.org/t/specify-type-of-function/18373 "2018-12-06T12:54:57Z")

</div>

Let’s say that I want to write a higher order function (a function that accepts another function) I know I can accept it like: fun(f::Function, args...) = ... What I want to know if it is possible to be more specific a…

---

## [Recipe for custom array types with metadata bound to it](https://discourse.julialang.org/t/recipe-for-custom-array-types-with-metadata-bound-to-it/18370)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 1\
**Last updated:** [December 6, 2018, 12:54pm UTC](https://discourse.julialang.org/t/recipe-for-custom-array-types-with-metadata-bound-to-it/18370 "2018-12-06T12:54:37Z")

</div>

I want to implement custom array type with some additional fields to store useful metadata information bound to that array. But, similar to OffsetArrays.jl, I want to implement it for any AbstractArray subtype (simple ar…

---

## [Julia 0.7/1.0 workflow](https://discourse.julialang.org/t/julia-0-7-1-0-workflow/13986)

<div class="topic-metadata">

**Author:** [@davidavdav](https://discourse.julialang.org/u/davidavdav)\
**Replies:** 5\
**Last updated:** [December 6, 2018, 12:32pm UTC](https://discourse.julialang.org/t/julia-0-7-1-0-workflow/13986 "2018-12-06T12:32:50Z")

</div>

Hello, What is the preferred/recommended workflow for developing/maintaining packages, in terms of interaction between developing code in an editor, julia-0.7, and testing the package. I am used to having a package Mym…

---

## [Not able to add any package. Julia terminal crash after executing "add xxxx"](https://discourse.julialang.org/t/not-able-to-add-any-package-julia-terminal-crash-after-executing-add-xxxx/18281)

<div class="topic-metadata">

**Author:** [@caffery-chen](https://discourse.julialang.org/u/caffery-chen)\
**Replies:** 14\
**Last updated:** [December 6, 2018, 1:19am UTC](https://discourse.julialang.org/t/not-able-to-add-any-package-julia-terminal-crash-after-executing-add-xxxx/18281 "2018-12-06T01:19:12Z")

</div>

I deleted .julia/registries folder. I was trying to install tensorflow. But I got the error and Julia terminal just terminated by itself. It seems the General git repo cannot cloned. (although I tried manually add the G…

---

## [Recommended approach for getproperty shadowing](https://discourse.julialang.org/t/recommended-approach-for-getproperty-shadowing/18312)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [December 5, 2018, 11:49pm UTC](https://discourse.julialang.org/t/recommended-approach-for-getproperty-shadowing/18312 "2018-12-05T23:49:14Z")

</div>

Suppose I have a wrapper type that has some contents I would like to index with symbols, for both getindex and getproperty syntaxes (if you want a concrete example, think of a DataFrame). However, this could be problema…

---

## [Save "lazy" dataset that is calculated from another saved datasets](https://discourse.julialang.org/t/save-lazy-dataset-that-is-calculated-from-another-saved-datasets/18283)

<div class="topic-metadata">

**Author:** [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Replies:** 3\
**Last updated:** [December 5, 2018, 9:37pm UTC](https://discourse.julialang.org/t/save-lazy-dataset-that-is-calculated-from-another-saved-datasets/18283 "2018-12-05T21:37:11Z")

</div>

Given some datasets A and B in a columnar storage (say, DataFrames), and another dataset C that is calculated based on A and B, e.g. C = A + B first derivative of A smoothed version of B etc. How can I save and lo…

---

## [First matching element in collection](https://discourse.julialang.org/t/first-matching-element-in-collection/18324)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [December 5, 2018, 7:43pm UTC](https://discourse.julialang.org/t/first-matching-element-in-collection/18324 "2018-12-05T19:43:16Z")

</div>

Sometimes I want to find the first element in a collection that satisfies some predicate f. The collection may not be (O(1)) indexable, so findfirst then lookup is not ideal. I am looking for something like function fi…

---

## [Defining custom pipe operator](https://discourse.julialang.org/t/defining-custom-pipe-operator/18315)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 10\
**Last updated:** [December 5, 2018, 5:33pm UTC](https://discourse.julialang.org/t/defining-custom-pipe-operator/18315 "2018-12-05T17:33:01Z")

</div>

Hello! I’m trying to define a pipe operator which propagates nothing. It sounds quite easy: ⇒(x, f) = x == nothing ? nothing : f(x). This operator works fine when there is a single application of it, e.g. \[1, 2, 3\] ⇒ col…

---

## [Julia 0.7 Upgrade issues with ODBC](https://discourse.julialang.org/t/julia-0-7-upgrade-issues-with-odbc/18327)

<div class="topic-metadata">

**Author:** [@acunningham](https://discourse.julialang.org/u/acunningham)\
**Replies:** 2\
**Last updated:** [December 5, 2018, 4:39pm UTC](https://discourse.julialang.org/t/julia-0-7-upgrade-issues-with-odbc/18327 "2018-12-05T16:39:59Z")

</div>

Hi, I’m currently in the process of upgrading our Julia 0.6 codebase to Julia 0.7, however I’m hitting a very weird issue with ODBC. If I call a method, any method prior to issuing a sql query the julia process starts …

---

## [Variable name style](https://discourse.julialang.org/t/variable-name-style/18305)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 4\
**Last updated:** [December 5, 2018, 10:23am UTC](https://discourse.julialang.org/t/variable-name-style/18305 "2018-12-05T10:23:07Z")

</div>

What’s your opinion? I tend to like single-letter variable names e.g. i, j, k for indices, w, h for width and height, s for any string, t for time, etc. Sometimes when I use meaningful / long names, I end up masking an…

---

## [Cannot build CUDANative: CUDA toolkit at doesn't contain nvcc?](https://discourse.julialang.org/t/cannot-build-cudanative-cuda-toolkit-at-doesnt-contain-nvcc/17614)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 1\
**Last updated:** [December 5, 2018, 12:38am UTC](https://discourse.julialang.org/t/cannot-build-cudanative-cuda-toolkit-at-doesnt-contain-nvcc/17614 "2018-12-05T00:38:56Z")

</div>

Using Julia 1.0.1 on Windows 10, I tried to install CuArrays but one of the dependencies, CUDANative, couldn’t be built properly, how can I solve this? julia\> Pkg.build("CUDAnative") Building LLVM ──────→ \`C:\\Users\\Se…

---

## [Complex number, abs() and IntervalArithmetic](https://discourse.julialang.org/t/complex-number-abs-and-intervalarithmetic/18268)

<div class="topic-metadata">

**Author:** [@OlivierHnt](https://discourse.julialang.org/u/OlivierHnt)\
**Replies:** 1\
**Last updated:** [December 4, 2018, 11:54pm UTC](https://discourse.julialang.org/t/complex-number-abs-and-intervalarithmetic/18268 "2018-12-04T23:54:30Z")

</div>

Good evening, I ran into an issue in my code earlier with IntervalArithmetic: julia\> abs.(\[0..0.01\] + \[0..1\]\*im) 1-element Array{Interval{Float64},1}: \[0, ∞\] julia\> norm(\[0..0.01\] + \[0..1\]\*im, 1) \[0, ∞\] However, t…

---

## [Passing an array of a C++ class to julia (CxxWrap)](https://discourse.julialang.org/t/passing-an-array-of-a-c-class-to-julia-cxxwrap/17622)

<div class="topic-metadata">

**Author:** [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Replies:** 4\
**Last updated:** [December 4, 2018, 2:03pm UTC](https://discourse.julialang.org/t/passing-an-array-of-a-c-class-to-julia-cxxwrap/17622 "2018-12-04T14:03:48Z")

</div>

Hi, I’ve been wrapping a C++ library with C++ wrap, and some of the methods in it return vectors, either of simple items like floats, and ints, or sometimes vectors of classes. I’ve come up with a way to give a std::ve…

---

## [Is it possible to modify ast by itself?](https://discourse.julialang.org/t/is-it-possible-to-modify-ast-by-itself/18267)

<div class="topic-metadata">

**Author:** [@xyyimian](https://discourse.julialang.org/u/xyyimian)\
**Replies:** 3\
**Last updated:** [December 4, 2018, 1:36pm UTC](https://discourse.julialang.org/t/is-it-possible-to-modify-ast-by-itself/18267 "2018-12-04T13:36:18Z")

</div>

Hi everyone, I am trying to write a julia debugger. I am wondering if it is possible to modify a block’s ast by itself. I tried like this: julia\> s = "function test1() println(1) println(…

---

## [Getindex with default value](https://discourse.julialang.org/t/getindex-with-default-value/18269)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 4\
**Last updated:** [December 4, 2018, 9:56am UTC](https://discourse.julialang.org/t/getindex-with-default-value/18269 "2018-12-04T09:56:54Z")

</div>

There is a nice convenience method of get, that allows to handle out of bounds access with a default value. julia\> get(\[1,2\],1000,"my default value") "my default value" Is there something analog for multidimensional in…

---

## [Extract intermediate data from inside a function](https://discourse.julialang.org/t/extract-intermediate-data-from-inside-a-function/18251)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 13\
**Last updated:** [December 4, 2018, 8:00am UTC](https://discourse.julialang.org/t/extract-intermediate-data-from-inside-a-function/18251 "2018-12-04T08:00:15Z")

</div>

Hi, here comes a question which in any other language would be wishful, yet in Julia, I dare wish. So I program a function R = f(X) think finite elements 101, given nodal displacements, the function returns nodal for…

---

## [Using Julia package manager offline](https://discourse.julialang.org/t/using-julia-package-manager-offline/17773)

<div class="topic-metadata">

**Author:** [@alirezamecheng](https://discourse.julialang.org/u/alirezamecheng)\
**Replies:** 6\
**Last updated:** [December 4, 2018, 6:28am UTC](https://discourse.julialang.org/t/using-julia-package-manager-offline/17773 "2018-12-04T06:28:56Z")

</div>

We recently decided to make Julia Language available on our cluster systems. The cluster system is not able to connect to the internet. Is there any way to download all Julia packages and make them available for our diff…

---

## [SegFault related to logging](https://discourse.julialang.org/t/segfault-related-to-logging/18260)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 0\
**Last updated:** [December 3, 2018, 6:38pm UTC](https://discourse.julialang.org/t/segfault-related-to-logging/18260 "2018-12-03T18:38:28Z")

</div>

Hi fellows, I am having trouble with my own logger. I am using Julia’s logging system. and the following write line gives me an error. However the println before it works just fine. #IOBuffer buf = IOBuffer(…

---

## [Reading a file line by line](https://discourse.julialang.org/t/reading-a-file-line-by-line/18256)

<div class="topic-metadata">

**Author:** [@Dhananjay\_Ghangale](https://discourse.julialang.org/u/Dhananjay_Ghangale)\
**Replies:** 3\
**Last updated:** [December 3, 2018, 5:00pm UTC](https://discourse.julialang.org/t/reading-a-file-line-by-line/18256 "2018-12-03T17:00:32Z")

</div>

Hi guys I have a difficult in writing a function that can read file line by line. I have a .dat file which needs to be read line by line. I had written the function in matlab and while writting the function i was using f…

---

## [Is there a function compute matrix multiplication in a multimensional matrix?](https://discourse.julialang.org/t/is-there-a-function-compute-matrix-multiplication-in-a-multimensional-matrix/18106)

<div class="topic-metadata">

**Author:** [@Dhananjay\_Ghangale](https://discourse.julialang.org/u/Dhananjay_Ghangale)\
**Replies:** 8\
**Last updated:** [December 3, 2018, 4:33pm UTC](https://discourse.julialang.org/t/is-there-a-function-compute-matrix-multiplication-in-a-multimensional-matrix/18106 "2018-12-03T16:33:27Z")

</div>

For matrices of n dimensions and same sizes is there a function that can compute matrix multiplication. for example in matlab there exists a function call mtimesx (MTIMESX - Fast Matrix Multiply with Multi-Dimensional S…

---

## [Avoiding recompilation with multiple projects?](https://discourse.julialang.org/t/avoiding-recompilation-with-multiple-projects/18250)

<div class="topic-metadata">

**Author:** [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Replies:** 4\
**Last updated:** [December 3, 2018, 4:11pm UTC](https://discourse.julialang.org/t/avoiding-recompilation-with-multiple-projects/18250 "2018-12-03T16:11:07Z")

</div>

I’ve been using a project based workflow where I have multiple projects that use different versions of the same packages: some use tagged versions, some use global dev versions, and some use local dev versions. This work…

---

## [ERROR: LoadError: MethodError: no method matching setindex\_shape\_check(::Int64, ::Int64, ::Int64)](https://discourse.julialang.org/t/error-loaderror-methoderror-no-method-matching-setindex-shape-check-int64-int64-int64/18249)

<div class="topic-metadata">

**Author:** [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Replies:** 3\
**Last updated:** [December 3, 2018, 2:43pm UTC](https://discourse.julialang.org/t/error-loaderror-methoderror-no-method-matching-setindex-shape-check-int64-int64-int64/18249 "2018-12-03T14:43:31Z")

</div>

Hello, using Julia 1.0.1, and i’m getting this error: ERROR: LoadError: MethodError: no method matching setindex\_shape\_check(::Int64, ::Int64, ::Int64) Closest candidates are: setindex\_shape\_check(::AbstractArray{#s57…

---

## [Problem with installation of AbstractAlgebra and Nano in Julia 1.0.2](https://discourse.julialang.org/t/problem-with-installation-of-abstractalgebra-and-nano-in-julia-1-0-2/18235)

<div class="topic-metadata">

**Author:** [@ayarodionov](https://discourse.julialang.org/u/ayarodionov)\
**Replies:** 2\
**Last updated:** [December 3, 2018, 1:11pm UTC](https://discourse.julialang.org/t/problem-with-installation-of-abstractalgebra-and-nano-in-julia-1-0-2/18235 "2018-12-03T13:11:58Z")

</div>

Hi All! I’m novice user. I tried to install “AbstractAlgebra” on julia version 1.0.2. I followed instaruction but got: julia\> Pkg.add(“AbstractAlgebra”) Resolving package versions… ERROR: The following package names…

---

## [GPU randn way slower than rand?](https://discourse.julialang.org/t/gpu-randn-way-slower-than-rand/18236)

<div class="topic-metadata">

**Author:** [@Zhiye\_Xia](https://discourse.julialang.org/u/Zhiye_Xia)\
**Replies:** 6\
**Last updated:** [December 3, 2018, 6:53am UTC](https://discourse.julialang.org/t/gpu-randn-way-slower-than-rand/18236 "2018-12-03T06:53:46Z")

</div>

I’m trying to generate random normals directly on GPU when I find the following result: using CuArrays using Random ac = Array{Float64}(undef, 2^20) ag = cu(ac) @time rand!(ac) @time rand!(ag) ac = Array{Float64}(undef,…

---

## [DataFrames / Using variables into a push command to fill dataframes](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220)

<div class="topic-metadata">

**Author:** [@Patrick\_Dubus](https://discourse.julialang.org/u/Patrick_Dubus)\
**Replies:** 2\
**Last updated:** [December 3, 2018, 4:31am UTC](https://discourse.julialang.org/t/dataframes-using-variables-into-a-push-command-to-fill-dataframes/18220 "2018-12-03T04:31:07Z")

</div>

Hello After creation of a DataFrame: xd = DataFrame(name=String,typ=Float64,min=Float64,max=Float64,law=String,avg=Float64,std=Float64) To simplify filling data, I used in the past the following command push!(xd,(nam…

---

## [Inexplicable allocations when summing \`StaticArrays\`](https://discourse.julialang.org/t/inexplicable-allocations-when-summing-staticarrays/18012)

<div class="topic-metadata">

**Author:** [@zygmuntszpak](https://discourse.julialang.org/u/zygmuntszpak)\
**Replies:** 8\
**Last updated:** [December 3, 2018, 1:25am UTC](https://discourse.julialang.org/t/inexplicable-allocations-when-summing-staticarrays/18012 "2018-12-03T01:25:08Z")

</div>

This is a cross-post from an issue I opened in the StaticArrays package: https://github.com/JuliaArrays/StaticArrays.jl/issues/537 I have been working on a pull-request to fix an issue I discovered with StaticArrays. I…

---

## [Accessing glade files in GTK](https://discourse.julialang.org/t/accessing-glade-files-in-gtk/18227)

<div class="topic-metadata">

**Author:** [@lkadgrjh](https://discourse.julialang.org/u/lkadgrjh)\
**Replies:** 2\
**Last updated:** [December 2, 2018, 9:14pm UTC](https://discourse.julialang.org/t/accessing-glade-files-in-gtk/18227 "2018-12-02T21:14:24Z")

</div>

I’m trying to learn glade/GTK in Julia, I have used TK in Python and TCL but have never used glade or GTK. Here is what I’m trying to do. The glade file is at the end of this post. Julia commands: julia\> using Gtk juli…

---

## [Passing function pointer to Cxx](https://discourse.julialang.org/t/passing-function-pointer-to-cxx/1159)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 7\
**Last updated:** [December 2, 2018, 11:55pm UTC](https://discourse.julialang.org/t/passing-function-pointer-to-cxx/1159 "2018-12-02T23:55:38Z")

</div>

I am using the Cxx.jl to wrap a C++ library. Now the C++ library has some methods that take function pointers as arguments. Is there a recommended way to wrap such a function? As a minimal example say I want to wrap usi…

---

## [ForwardDiff: Using on functions that are defined on floats64](https://discourse.julialang.org/t/forwarddiff-using-on-functions-that-are-defined-on-floats64/18226)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 8\
**Last updated:** [December 2, 2018, 10:44pm UTC](https://discourse.julialang.org/t/forwarddiff-using-on-functions-that-are-defined-on-floats64/18226 "2018-12-02T22:44:13Z")

</div>

I understand that ForwardDiff works with Dual Numbers, so far example this throws an error: f(x::Float64) = x^2 f\_diff(x) = ForwardDiff.derivative(f, x) f\_diff(2.0) ERROR: MethodError: no method matching f(::ForwardDiff…

---

## [Unexpected memory allocation from @timev?](https://discourse.julialang.org/t/unexpected-memory-allocation-from-timev/18223)

<div class="topic-metadata">

**Author:** [@drmartinrohde](https://discourse.julialang.org/u/drmartinrohde)\
**Replies:** 5\
**Last updated:** [December 2, 2018, 6:29pm UTC](https://discourse.julialang.org/t/unexpected-memory-allocation-from-timev/18223 "2018-12-02T18:29:41Z")

</div>

I have written a piece of code consisting of hundreds of lines. Everything is defined in functions. When running this code, I basically calculate a temperature profile along a loop in time. After running this code and ch…

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

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