asc-community / asc-community/HonkSharp

Built-in memoization

Open
#23 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
HTML
Stars
49
Forks
4
PR merge metrics
No merged PRs in 30d

Description

With recursion. Example of code:

## PoC

```cs
using System;
using System.Collections.Generic;
using static Memes;

var fib = Memoize((n, fib) =>
n switch
{
<= 1 => 1,
var m => fib(n - 1) + fib(n - 2)
});
Console.WriteLine(fib(40));

public static class Memes
{
public static Func Memoize(Func, TOut> func)
{
var dic = new Dictionary();
Func rec = null;
rec = tin =>
{
if (dic.TryGetValue(tin, out var res))
return res;
res = func(tin, rec);
dic[tin] = res;
return res;
};
return rec;
}
}
```

## API

```cs
public static Func Memoize(Func> func);
public static (Func, Func) Memoize(Func, Func, TOut1> func1, Func, Func, TOut2> func2);
...

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start from the recursive Memoize proof of concept and the proposed API signatures in the issue; locate where HonkSharp exposes its existing wrappers and methods. Determine the supported overload scope and verify recursive calls and cached results with focused tests. The issue is done when the agreed built-in memoization API and its behavior are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.