Memoize a vararg function

gmouts
Fri, 25 May 2018 18:40:49 +0000
General Usage

I tried to use Memoize.jl fro a vararg function. The following code

@memoize function test(lst::Vararg{Int})
    return length(lst)
end

test(1,2)

gives

TypeError: test: in typeassert, expected Vararg{Int64,N} where N, got Tuple{Int64,Int64}

I flagged it as bug but I am not sure if it is actually. It seems that since Tuple{Int64,Int64} is not a subtype of Vararg{Int64,N} where N the macro cannot work, but I don’t know whether trying to fix that will break something else.

Anyway, is it possible to memoize such functions at the moment? Will this be fixed in the future?

4 posts - 3 participants