Combining Tries
See original GitHub issueHi,
I am trying to build higher abstraction based on smaller Try function components but resulting “combination” is eager in result instead of being lazy:
namespace LanguageExtTesting
{
class Program
{
static Try<int> Parse(string str) => () => int.Parse(str);
static Try<int> Sum(string lhs, string rhs)
=> from x in Parse(rhs)
from y in Parse(lhs)
select x + y;
static void Main(string[] args)
{
var trySum = Sum("1r", "2"); // 1. throws here
var i = trySum.Try(); // 2. instead of here
}
}
}
problem here is that Program currently throws in the line 1. instead of line 2. . I tried wrapping LING expression within Sum() function with additional “() =>” but then I am getting compilation error of Result<T> not being convertible to <T>.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Merge two binary trie - algorithm
This way you only spend time merging the nodes that are ambiguous and you can copy/move entire subtrees in one go.
Read more >Trying to Understand Tries
Well, the truth is that they're rarely used exclusively; usually, they're used in combination with another structure, or in the context of an ......
Read more >Types of Tries
Tries are classified into three categories: Standard Trie · Compressed Trie ... Each node or branch may have multiple branches.
Read more >Tries | Brilliant Math & Science Wiki
Tries (also known as radix trees or prefix trees) are tree-based data structures that are typically used to store associative arrays where the...
Read more >What are tries and their types?
A compressed trie is a compact representation of a standard trie. If we have a node with one child, we try to merge...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. It is one is the correct ways.
@slimshader Don’t use
Try<A>.Try()
directly, use the other extension methods ofTry<A>
to work with the value. So,Try<A>.Match(...)
,Try<A>.IfFail(...)
, etc.