All Questions
9 questions
0
votes
1
answer
169
views
How to return value from a function
Hy there,
I am very new to programming, I have a code that can print all combination of size "k" from an array of size "n". but I want to use that information for further calculations. What should I ...
1
vote
1
answer
1k
views
Set a weight to each item in a list [closed]
I have got a comma-separated list of fruits, and they are listed in order from most-relevant to least-relevant.
e.g:
"fruits":"apple, orange, lemon, apple, strawberry, pineapple, banana"
I need to ...
0
votes
2
answers
93
views
C# a function with one argument of type T that returns a function with one argument of type T, but in fact needs more arguments
I have a Dictionary<T, IEnumerable<T>> that encodes a tree:
The keys represent all nodes of the tree and the values are the children of the corresponding nodes.
If a node does not have ...
3
votes
1
answer
507
views
The benefits of tail-recursion [duplicate]
If I got right, smart compilers detect tail-recursive functions and convert it to an iterative function.
So besides the benefits of writing in a functional style (immutability, function-independence ...
3
votes
3
answers
462
views
How to write a recursive function in C# that looks like A(key, B(key, C(key, ValFactory(key))))?
How do you write a function that has this form:
A(key, B(key, C(key, ValFactory(key))))
Where A, B, and C have this signature:
TResult GetOrAdd(string key, Func<string, TResult> generator);
...
2
votes
1
answer
158
views
Festival of Functional Regex Recursion - reconstruct particular string from this butchered one
In:
53_2_b
50
48_1_b_i
50A_3_b
48_1_b_iv
Out:
53(2)(b)
50
48(1)(b)(i)
50A(3)(b)
48(1)(b)(iv)
(They are section references from legislation which have been converted to NCNames. I want to unconvert ...
5
votes
4
answers
971
views
Recursive Functions, Stack Overflows, and Y-Combinators
I have a recursive function (in C#) that I need to call about 800 million times; this would obviously normally result in a stack overflow after about the 900th call. I've kicked this out to multiple ...
2
votes
3
answers
228
views
Recursively execute funcs in list
Given a list of Func<string, string>, is it possible to write a statement that iterates through the list and returns the result like so:
string result = f1(f2(f..(input));
I have the following ...
19
votes
5
answers
14k
views
In C# is it a good practice to use recursive functions in algorithms? [closed]
In many functional languages using a recursion is considered to be a good practice. I think it is good because of the way compiler optimizes functional language's code.
But is it a good practice to ...