On Sun, Oct 16, 2016 at 12:01 PM, Páll Haraldsson <pall.haralds...@gmail.com
> wrote:

## Advertising

>
> I was prototyping:
>
> julia> a=[1,2,3,1,2]
>
> julia> b=[a[i]<a[i+1] for i in 1:length(a)-1]
> 4-element Array{Bool,1}:
> true
> true
> false
> true
>
>
> In the beginning when trying stuff out I used:
>
> for i in a[1:end-1]
>
> or
>
> for i in a[2:end]
>
> and it got me thinking, end-1 works for any kind of array, but 1 as the
> start (or 2) is not correct in general. For e.g. general (e.g. zero-based
> arrays now allowed), what do you do? [If I need all: for i in a just works]
>
>
Not decided yet. Ref https://github.com/JuliaLang/julia/pull/15750
>
> In the beginning, because of error, there seemed to be no bounds checking,
> but since it's there, is there a way do disable?
>
>
> julia> b=[@inbounds a[i]<a[i+1] for i in 1:length(a)-1]
> 4-element Array{Void,1}:
> nothing
> nothing
> nothing
> nothing
>
> julia> b=[(@inbounds (a[i]<a[i+1]) for i in 1:length(a)-1)]
> 1-element Array{Base.Generator{UnitRange{Int64},##59#60},1}:
> Base.Generator{UnitRange{Int64},##59#60}(#59,1:4)
>
>
>
https://github.com/JuliaLang/julia/pull/15558
You can always use an assignment in a composite expression.
>
> Eventually I want something different, the points where, increasing turn
> to decreasing (or vice versa), at most n/2 points. Array comprehension is
> probably not the right way, as I need to know how many point.
>
> I'll change to a loop (that will be itself in a loop), that uses a
> preallocated array for result, I want to reuse that in each iteration of
> the outer loop; I assume that isn't possible with an array comprehension.
>
>