Memoize a vararg function



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

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



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?


This seems like a bug, it really ought to check against NTuple{N,Int} wherever it’s doing that. For the hell of it, you might try my package Anamnesis.jl and see if you get the same error, though to be honest I’m not quite sure if I supported that.

I never registered Anamnesis so you’d have to clone it.

You might also try doing

@memoize function test(lst::Int...) = length(lst)

it shouldn’t make a difference but might be worth a shot.


After I clone it, how do I tell Julia to use it?


Same way as with any other package.

using Anamnesis