Python Development, memoized functions.

Antti Karttunen antti.karttunen at gmail.com
Thu Jan 4 13:11:05 CET 2007


Antti Karttunen wrote:

> ...
> we can assume the existence of a "memoizating" decorator
> with just name M, so that A000045 could then just have a line like:
>
> %o A000045 (Python) @M def A000045(n):  if(n < 2): return(n) else: 
> return(A000045(n-1)+A000045(n-2))
>
> and this is then to be interpreted as
> @M
> def A000045(n):  if(n < 2): return(n) else: 
> return(A000045(n-1)+A000045(n-2))
>
Or even better, because there are already comments about deleting 
leading periods,
we can have another kind of comment like this:

%o A000045 (Python, use the decorator @M:) def A000045(n): if(n < 2): 
return(n) else: return(A000045(n-1)+A000045(n-2))

>
> Cheers,
>
> Antti
>
>
>






More information about the SeqFan mailing list