Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # List slicing
- function getSlice(x::Array{T, 1}, a::Int64, z::Int64, n::Int64) where T <: Any
- b = a + z - 1;
- if b > n
- return vcat(x[a:end], NaN*ones(b-n));
- else
- return x[a:b];
- end
- end
- function main(x::Array{T, 1}, sl::Array{Int64, 1}) where T <: Any
- n = length(x);
- ns = length(sl);
- y = Array{Array{Real, 1}}(undef, ns);
- a = 1;
- for i = 1:ns
- y[i] = getSlice(x, a, sl[i], n);
- a += sl[i];
- end
- return y;
- end
Add Comment
Please, Sign In to add comment