Re: [julia-users] Define `similar` function for a custom array

2015-02-06 Thread Steven G. Johnson
> Finally, your size() function should return a tuple with one element > instead of a scalar. You should also have a length function, like this: > Base.length(s::Ngram) = length(s.seq) - s.n + 1 > Base.size(s::Ngram) = (length(s),) > Note that length(s) is automatically defined if you supply a

Re: [julia-users] Define `similar` function for a custom array

2015-02-06 Thread Milan Bouchet-Valat
Le vendredi 06 février 2015 à 03:48 -0800, Ivar Nesje a écrit : > Please don't tell him to use +1 and -1 to manipulate UTF8String > indexes. Use nextind and prevind. Indeed, shame on me, for somebody who's trying to forbid indexing strings with integers... So, if you want to support strings other

Re: [julia-users] Define `similar` function for a custom array

2015-02-06 Thread Ivar Nesje
Please don't tell him to use +1 and -1 to manipulate UTF8String indexes. Use nextind and prevind.

Re: [julia-users] Define `similar` function for a custom array

2015-02-06 Thread Milan Bouchet-Valat
Le jeudi 05 février 2015 à 23:58 -0800, Wai Yip Tung a écrit : > The idea of Ngram is that it is a view of N string of length k without > using k times as much memory. I would like to preform operation the > set of Ngram string, let's say unique(). In those cases I expect it to > be treat as 1 dime

Re: [julia-users] Define `similar` function for a custom array

2015-02-05 Thread Wai Yip Tung
The idea of Ngram is that it is a view of N string of length k without using k times as much memory. I would like to preform operation the set of Ngram string, let's say unique(). In those cases I expect it to be treat as 1 dimension Array of String. I am making some progress with similar defin

Re: [julia-users] Define `similar` function for a custom array

2015-02-05 Thread Milan Bouchet-Valat
Le mercredi 04 février 2015 à 23:11 -0800, Wai Yip Tung a écrit : > I have successfully defined a custom array Ngram. > > > > type Ngram <: AbstractArray{ASCIIString,1} > seq::ASCIIString > n::Int > end > > > function getindex(s::Ngram, i::Int) > s.seq[i:i+s.n-1] > end > > > func

[julia-users] Define `similar` function for a custom array

2015-02-04 Thread Wai Yip Tung
I have successfully defined a custom array Ngram. type Ngram <: AbstractArray{ASCIIString,1} seq::ASCIIString n::Int end function getindex(s::Ngram, i::Int) s.seq[i:i+s.n-1] end function Base.size(s::Ngram) length(s.seq) - s.n + 1 end It works as I expected. For example In [21