# General Usage

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

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

**Page:** 1015

---

## [Macro Question / Type Problem](https://discourse.julialang.org/t/macro-question-type-problem/7168)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [November 19, 2017, 9:33pm UTC](https://discourse.julialang.org/t/macro-question-type-problem/7168 "2017-11-19T21:33:23Z")

</div>

function instrument(f1::EvaluatorFunction, f2::TrapFunction, ex::Expr) # returns an expr after modifying ex end function instrument(trap\_fun::TrapFunction, ex::Expr ;amod = current\_module()) ins…

---

## [How to ceiling all Array{DateTime,1} ? ceil.(stopISO,Dates.Minute) not work](https://discourse.julialang.org/t/how-to-ceiling-all-array-datetime-1-ceil-stopiso-dates-minute-not-work/7152)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 3\
**Last updated:** [November 19, 2017, 8:02pm UTC](https://discourse.julialang.org/t/how-to-ceiling-all-array-datetime-1-ceil-stopiso-dates-minute-not-work/7152 "2017-11-19T20:02:14Z")

</div>

julia\> typeof(stopISO) Array{DateTime,1} julia\> size(stopISO) (66092,) How to ceiling all Array{DateTime,1} ? ceil.(stopISO,Dates.Minute) not work. julia\> eltype(stopISO) DateTime julia\> ceil(stopISO\[1\],Dates.Minu…

---

## [Making use of precompile](https://discourse.julialang.org/t/making-use-of-precompile/7171)

<div class="topic-metadata">

**Author:** [@Mattes](https://discourse.julialang.org/u/Mattes)\
**Replies:** 1\
**Last updated:** [November 19, 2017, 7:00pm UTC](https://discourse.julialang.org/t/making-use-of-precompile/7171 "2017-11-19T19:00:19Z")

</div>

I have a very simple program using ArgParse.jl: using ArgParse function main(args) s = ArgParseSettings(description = "Example 1 for argparse.jl: minimal usage.") @add\_arg\_table s begin "--max\_n", "-N"…

---

## [Performance of Julia as a general-purpose programming language](https://discourse.julialang.org/t/performance-of-julia-as-a-general-purpose-programming-language/6995)

<div class="topic-metadata">

**Author:** [@juliendehos](https://discourse.julialang.org/u/juliendehos)\
**Replies:** 30\
**Last updated:** [November 19, 2017, 10:28am UTC](https://discourse.julialang.org/t/performance-of-julia-as-a-general-purpose-programming-language/6995 "2017-11-19T10:28:56Z")

</div>

Hi, I used Julia for a “computing” project recently and it was really nice. Now, I’m tempted to use Julia for a more “classic” project (involving tree-like data-structures) so I’ve implemented a test project (the tictac…

---

## [\`@propagate\_inbounds\` and \`@boundscheck\` vs \`checkbounds\`](https://discourse.julialang.org/t/propagate-inbounds-and-boundscheck-vs-checkbounds/7147)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 8\
**Last updated:** [November 18, 2017, 9:42pm UTC](https://discourse.julialang.org/t/propagate-inbounds-and-boundscheck-vs-checkbounds/7147 "2017-11-18T21:42:47Z")

</div>

checkbounds is intuitive, but how does it compare and work with the other 2? Pulled from the following example in JuAFEM.jl: @propagate\_inbounds function assemble!(g::AbstractVector{T}, edof::AbstractVector{Int}, ge::Ab…

---

## [Subtypes of an abstract type](https://discourse.julialang.org/t/subtypes-of-an-abstract-type/7151)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [November 18, 2017, 7:25pm UTC](https://discourse.julialang.org/t/subtypes-of-an-abstract-type/7151 "2017-11-18T19:25:48Z")

</div>

Hi, Is there a function which takes an argument and returns a list of that argument’s subtypes. Example: abstract X type Y \<:X end type Z \<:X end get\_subtypes(X) will return \[:Y,:Z\] Thanks

---

## [Help understanding example dealing with @async/wait/yield/schedule in Redefining Methods section](https://discourse.julialang.org/t/help-understanding-example-dealing-with-async-wait-yield-schedule-in-redefining-methods-section/6980)

<div class="topic-metadata">

**Author:** [@angelv](https://discourse.julialang.org/u/angelv)\
**Replies:** 1\
**Last updated:** [November 18, 2017, 5:44pm UTC](https://discourse.julialang.org/t/help-understanding-example-dealing-with-async-wait-yield-schedule-in-redefining-methods-section/6980 "2017-11-18T17:44:45Z")

</div>

Hi, I’m reading the Redefining Methods section (https://docs.julialang.org/en/stable/manual/methods/#Redefining-Methods-1), and I don’t understand it properly. The lines that give me some trouble are: julia\> f(x::Int)…

---

## [Crash/stackoverflow when calling constructor with too many inputs](https://discourse.julialang.org/t/crash-stackoverflow-when-calling-constructor-with-too-many-inputs/7116)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 6\
**Last updated:** [November 18, 2017, 11:01am UTC](https://discourse.julialang.org/t/crash-stackoverflow-when-calling-constructor-with-too-many-inputs/7116 "2017-11-18T11:01:50Z")

</div>

I’m writing some code where I define vectors and points in homogeneous coordinates. To this end, I inherit from StaticArrays.FieldVector with length N+1, in order to enforce the invariant that the last coordinate be equa…

---

## [Help newbie to understand type stability please](https://discourse.julialang.org/t/help-newbie-to-understand-type-stability-please/7119)

<div class="topic-metadata">

**Author:** [@Liso](https://discourse.julialang.org/u/Liso)\
**Replies:** 7\
**Last updated:** [November 17, 2017, 12:48pm UTC](https://discourse.julialang.org/t/help-newbie-to-understand-type-stability-please/7119 "2017-11-17T12:48:24Z")

</div>

Could anybody please help me improve my understanding of what looks like strange behavior? function good1(x::Array{T,1}) where T\<:Float64 n = length(x) x \*= 1 # problem is not here \[i for i in x\] end funct…

---

## [How to get best from string dateformat to yyyy-mm-dd](https://discourse.julialang.org/t/how-to-get-best-from-string-dateformat-to-yyyy-mm-dd/7106)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [November 16, 2017, 7:05pm UTC](https://discourse.julialang.org/t/how-to-get-best-from-string-dateformat-to-yyyy-mm-dd/7106 "2017-11-16T19:05:04Z")

</div>

I have the following date format: “November 10, 2017, 01:15:58 PM” and want to change it to a more standard “yyyy-mm-dd”. Is there any smart way to go about it?

---

## [Use only the x first letters of strings inside a columns of a DataFrame](https://discourse.julialang.org/t/use-only-the-x-first-letters-of-strings-inside-a-columns-of-a-dataframe/6979)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 4\
**Last updated:** [November 16, 2017, 6:55pm UTC](https://discourse.julialang.org/t/use-only-the-x-first-letters-of-strings-inside-a-columns-of-a-dataframe/6979 "2017-11-16T18:55:51Z")

</div>

Hi everyone, I have a DataFrame with a column that contains strings. I would like to take all those strings, take only the nine first letters and save the resulting column of strings back into the DataFrame. What is th…

---

## [Instantiating a SharedArray with a Vector{Float64}](https://discourse.julialang.org/t/instantiating-a-sharedarray-with-a-vector-float64/746)

<div class="topic-metadata">

**Author:** [@CorbinFoucart](https://discourse.julialang.org/u/CorbinFoucart)\
**Replies:** 3\
**Last updated:** [November 16, 2017, 12:03pm UTC](https://discourse.julialang.org/t/instantiating-a-sharedarray-with-a-vector-float64/746 "2017-11-16T12:03:10Z")

</div>

I can initialize a SharedArray the usual way SharedArray(Float64, (180, 1)) and get an empty shared array. However, I would like to initialize the array by casting an already existing vector to the shared array. Is thi…

---

## [Understanding type stability](https://discourse.julialang.org/t/understanding-type-stability/6953)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon](https://discourse.julialang.org/u/Philippe_Maincon)\
**Replies:** 16\
**Last updated:** [November 16, 2017, 10:12am UTC](https://discourse.julialang.org/t/understanding-type-stability/6953 "2017-11-16T10:12:04Z")

</div>

For my FEM work, I want to be able to multiply higher dimension arrays with each other, as in “cartensian tensors”. I know there are packages, I want to learn. Function dots2 is specialised to multiply 3-Arrays with ve…

---

## [Way to add computed properties to a type?](https://discourse.julialang.org/t/way-to-add-computed-properties-to-a-type/7094)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 1\
**Last updated:** [November 16, 2017, 6:01am UTC](https://discourse.julialang.org/t/way-to-add-computed-properties-to-a-type/7094 "2017-11-16T06:01:41Z")

</div>

Let’s say you have a type: struct User first\_name::AbstractString last\_name::AbstractString end Is there a way to have a computed property called name on User that calls a function (and maybe caches it) using t…

---

## [Overhead of dynamic dispatch?](https://discourse.julialang.org/t/overhead-of-dynamic-dispatch/7089)

<div class="topic-metadata">

**Author:** [@TravisA9](https://discourse.julialang.org/u/TravisA9)\
**Replies:** 4\
**Last updated:** [November 15, 2017, 8:01pm UTC](https://discourse.julialang.org/t/overhead-of-dynamic-dispatch/7089 "2017-11-15T20:01:14Z")

</div>

I’m curious about the overhead Vs. benefits of using types. I did see mention of a related subject in julia docs but I think my question is slightly different. It seems reasonable to believe that there is some sort of ov…

---

## [Using axpy!](https://discourse.julialang.org/t/using-axpy/7072)

<div class="topic-metadata">

**Author:** [@mforets](https://discourse.julialang.org/u/mforets)\
**Replies:** 12\
**Last updated:** [November 15, 2017, 1:52pm UTC](https://discourse.julialang.org/t/using-axpy/7072 "2017-11-15T13:52:49Z")

</div>

The operation of multiplication by a scalar and translation can be done with Base.LinAlg.axpy!(α, x, y). But I can also use y .+= α\*x. I was wondering: is it recommended to use one or the other for writing library code?…

---

## [Terminal Graphics Interfaces](https://discourse.julialang.org/t/terminal-graphics-interfaces/7085)

<div class="topic-metadata">

**Author:** [@usefulhyun](https://discourse.julialang.org/u/usefulhyun)\
**Replies:** 2\
**Last updated:** [November 15, 2017, 1:31pm UTC](https://discourse.julialang.org/t/terminal-graphics-interfaces/7085 "2017-11-15T13:31:59Z")

</div>

Hi, there. I want to create a simple terminal game in Julia. I have experiences creating games in C terminal. But I do not know how can I do this in Julia. In C, I can use goto function to draw something where I want…

---

## [Searchsortedfirst and searchsortedlast](https://discourse.julialang.org/t/searchsortedfirst-and-searchsortedlast/7084)

<div class="topic-metadata">

**Author:** [@mottodora](https://discourse.julialang.org/u/mottodora)\
**Replies:** 4\
**Last updated:** [November 15, 2017, 1:10pm UTC](https://discourse.julialang.org/t/searchsortedfirst-and-searchsortedlast/7084 "2017-11-15T13:10:32Z")

</div>

lt(less than) function argument order of searchsortedfirst is different from that of searchsortedlast. Is this specification?

---

## [Empty output file when using Julia with the PBS system](https://discourse.julialang.org/t/empty-output-file-when-using-julia-with-the-pbs-system/7078)

<div class="topic-metadata">

**Author:** [@111](https://discourse.julialang.org/u/111)\
**Replies:** 2\
**Last updated:** [November 15, 2017, 12:13pm UTC](https://discourse.julialang.org/t/empty-output-file-when-using-julia-with-the-pbs-system/7078 "2017-11-15T12:13:00Z")

</div>

I wrote a code, and ran it in a cluster. The PBS system is used in this cluster. In my code, i use this sentence to record how much has been done @printf "calculated %.2f%% \\t" 100\*i/nt; println(now()) In the PBS scrip…

---

## [Keybinding in Juno/Atom to set working directory?](https://discourse.julialang.org/t/keybinding-in-juno-atom-to-set-working-directory/7062)

<div class="topic-metadata">

**Author:** [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Replies:** 2\
**Last updated:** [November 14, 2017, 5:52pm UTC](https://discourse.julialang.org/t/keybinding-in-juno-atom-to-set-working-directory/7062 "2017-11-14T17:52:09Z")

</div>

In Juno/Atom, there is the option to set the working directory to the location of the file being edited, using the PAckages-\>Julia-\>Working Directory-\>Current File’s Folder option (see shot) How can I set a keybinding f…

---

## [Failed to precompile Gadfly](https://discourse.julialang.org/t/failed-to-precompile-gadfly/7073)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 0\
**Last updated:** [November 14, 2017, 5:24pm UTC](https://discourse.julialang.org/t/failed-to-precompile-gadfly/7073 "2017-11-14T17:24:04Z")

</div>

When I tried to use the Gadfly package, I got the error message: Failed to precompile Gadfly to /home/Yifan/.julia/lib/v0.6/Gadfly.ji. compilecache(::String) at loading.jl:703 \_require(::Symbol) at loading.jl:490 requir…

---

## [Importing big data](https://discourse.julialang.org/t/importing-big-data/7030)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 21\
**Last updated:** [November 14, 2017, 2:31pm UTC](https://discourse.julialang.org/t/importing-big-data/7030 "2017-11-14T14:31:21Z")

</div>

I need to deal with tick-by-tick stock quote data with large size every day, I was wondering if Julia has any package that enables me to read csv/txt data with a size of more than 20GB. I used to use the sparklyr packag…

---

## [Warning message when using Julia in Atom](https://discourse.julialang.org/t/warning-message-when-using-julia-in-atom/7059)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 1\
**Last updated:** [November 14, 2017, 2:01pm UTC](https://discourse.julialang.org/t/warning-message-when-using-julia-in-atom/7059 "2017-11-14T14:01:13Z")

</div>

When I start Julia or using any packages in Atom, I got the warning message: sh: module: line 1: syntax error: unexpected end of file sh: error importing function definition for \`BASH\_FUNC\_module' sh: scl: line 1: synta…

---

## [Do-block for combining structures](https://discourse.julialang.org/t/do-block-for-combining-structures/7053)

<div class="topic-metadata">

**Author:** [@igor.cerovsky](https://discourse.julialang.org/u/igor.cerovsky)\
**Replies:** 2\
**Last updated:** [November 14, 2017, 8:45am UTC](https://discourse.julialang.org/t/do-block-for-combining-structures/7053 "2017-11-14T08:45:59Z")

</div>

Trying to find an example for the do-block syntax a I came to the following code: the anonymous function/closure in the do-block combines input arguments into a resulting structure. Is the code below correct as an exampl…

---

## [PyPlot not working properly](https://discourse.julialang.org/t/pyplot-not-working-properly/7060)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)\
**Replies:** 2\
**Last updated:** [November 14, 2017, 6:58am UTC](https://discourse.julialang.org/t/pyplot-not-working-properly/7060 "2017-11-14T06:58:12Z")

</div>

I am using Julia 0.6.0 in Atom and I have installed Plots.jl and PyPlot.jl, so I tried the codes below: function fn1(x) y = (x-1.1)^2 - 0.5 return y end x = collect(-3:6/99:6) plot…

---

## [Workaround for traditional inheritance features in object-oriented languages](https://discourse.julialang.org/t/workaround-for-traditional-inheritance-features-in-object-oriented-languages/1195)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 40\
**Last updated:** [November 14, 2017, 3:03am UTC](https://discourse.julialang.org/t/workaround-for-traditional-inheritance-features-in-object-oriented-languages/1195 "2017-11-14T03:03:04Z")

</div>

I am using the Julia type system seriously for the first time and have just learned that it doesn’t support inheritance from non-abstract types nor multiple inheritance. This statement applies to Julia v0.5. Could you p…

---

## [Why @parallel doing nothing?](https://discourse.julialang.org/t/why-parallel-doing-nothing/7010)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 11\
**Last updated:** [November 13, 2017, 11:05pm UTC](https://discourse.julialang.org/t/why-parallel-doing-nothing/7010 "2017-11-13T23:05:36Z")

</div>

Julia 5.0 Why my @parallel doing nothing ? all other proceses are OK . julia\>addprocs(5) … file=jldopen(“U\_baza\_Ski\\S\_Ski”) julia\> tic() 0x000015af252b402e julia\> @parallel for i=0:l-1 eval(parse(“S=read(file,"…

---

## [Problem solving a system of equations using SymPy](https://discourse.julialang.org/t/problem-solving-a-system-of-equations-using-sympy/7051)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 2\
**Last updated:** [November 13, 2017, 9:41pm UTC](https://discourse.julialang.org/t/problem-solving-a-system-of-equations-using-sympy/7051 "2017-11-13T21:41:33Z")

</div>

I am trying to solve a system of equations: using SymPy @syms F\_t delta F\_a beta\_c F\_tp F\_ap g\_p theta v lambda g = 9.81 m = 9.2; r = 30; eq1 = F\_t\*cos(delta) - F\_a\*cos(theta) + m\*g\*sin(beta\_c) eq2 = (m\*v^2)/r - F\_t\*sin…

---

## [Dot product of two row vectors](https://discourse.julialang.org/t/dot-product-of-two-row-vectors/7038)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 7\
**Last updated:** [November 13, 2017, 6:43pm UTC](https://discourse.julialang.org/t/dot-product-of-two-row-vectors/7038 "2017-11-13T18:43:51Z")

</div>

Why is it not allowed to calculate the dot product of two row vectors? Example: julia\> b=ones(3)' 1×3 RowVector{Float64,Array{Float64,1}}: 1.0 1.0 1.0 julia\> a=ones(3)' 1×3 RowVector{Float64,Array{Float64,1}}: 1.0…

---

## [Test xlabel in Winston plot](https://discourse.julialang.org/t/test-xlabel-in-winston-plot/7046)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 0\
**Last updated:** [November 13, 2017, 5:50pm UTC](https://discourse.julialang.org/t/test-xlabel-in-winston-plot/7046 "2017-11-13T17:50:22Z")

</div>

How to use string to lebeling x axis in Winston? julia\> plot(\[“a”,“b”,“c”\],rand(3)) ERROR: eltype of argument #1 is not Real or Complex in #plot#103(::Array{Any,1}, ::Function, ::Winston.FramedPlot tractArray{T,2},Ab…

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

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