An optimization technique where function calls are cached to avoid duplicate computations.

learn more… | top users | synonyms

1
vote
1answer
19 views

Levenshtein Distance with Haskell Vectors and Memoization

Is the following an effective way to implement the Levenshtein Distance with Haskell vectors? ...
1
vote
1answer
42 views

Memoization of Fibonacci using generic Int => Int helper

I'm trying to understand memoization using Scala. I took the Fibonacci sequence as an example because of the high cost of recursively computing numbers in the sequence without memoization. ...
1
vote
2answers
41 views

Lazy properties for the angle and length of a line segment

The code below shows the pattern I use to manage properties in my classes when I have the following requirements: Some properties are slow to calculate and are rarely used, so I want them to be lazy ...
2
votes
0answers
49 views

Making a default value a property

I recently asked a question on StackOverflow, looking for a way to more easily turn a class attribute into a @property, but only if no other value has been provided ...
2
votes
2answers
123 views

Pascal's triangle in PHP

Are there any optimization suggestions? ...
4
votes
1answer
88 views

Universal memoization decorator

I've just written a simple caching / memoization python decorator. It's purpose is to cache what the function returns for all the arguments combinations it's been ever invoked with. So, if, say, we ...
3
votes
1answer
142 views

Google CodeJam Round D APAC Test

Problem A: Vincenzo decides to make cube IV but only has the budget to make a square maze. Its a perfect maze, every room is in the form of a square and there are 4 doors (1 on each side of the ...
4
votes
1answer
112 views

Python caching generator

Is this the correct way to cache a generator in Python, without iterating over it right away (for example using list() over it)? ...
4
votes
1answer
101 views

Comparison of Fibonacci (Multinacci) Functions in Python3

After coming up with a formula on this Stack Overflow question, defeating recursion limits and finding a few new ways of calculating these numbers (as per this Stack Overflow question), I decided that ...
11
votes
5answers
2k views

Dynamic programming with Fibonacci

I have written the following code using a dynamic programming technique. Can I use ArrayList here? Please let me know if I can improve this code. ...
6
votes
1answer
822 views

Memoized Fibonacci

I went ahead and implemented a method to calculate Fibonacci numbers using memoization. ...
4
votes
2answers
137 views

Memoization helper

Please review: ...
6
votes
1answer
439 views

Generic pure functions memoization

I like to create tools for memoization since it can sometimes be useful. I recently created a generic tool for memoizing the results of pure functions. Here is an example of how it works: ...
3
votes
1answer
351 views

Iterative Collatz with memoization

I'm trying to write efficient code for calculating the chain-length of each number. For example, ...
5
votes
2answers
327 views

Helper class to memoize DateFormats application-wide

Premise Consider the following method: static String formatMyDate(Date date) { return new SimpleDateFormat("yyyy-MM-dd").format(date); } It's often ...
4
votes
2answers
96 views

Elegant memoizing

I wanted an elegant way to implement memoizing. Here is what I came up with: ...
6
votes
1answer
748 views

Ability to forget the memoized supplier value

Guava has a feature request which is asking to provide the ability to forget memoized value on a given supplier. On top on that I needed another functionality where if during the calculation of ...
2
votes
2answers
824 views

Python memoization decorator

I have spent all night whipping up this recipe. It's my first Python decorator. I feel like I have a full understanding of how decorators work now and I think I came up with a good object-oriented ...
2
votes
3answers
484 views

Memoization-based puzzle solution - sums in a triangle

I am trying to solve a problem at Codechef. As I am new to programming, I am not familiar with dynamic programming. However, I do know the basics of recursion and memoization. Hence I implemented a ...
10
votes
1answer
470 views

Utility functions for supporting memoization for functions

I've got a couple of utility functions to support memoization for functions with anywhere between 0 to 8 arguments: ...