4
votes
1answer
211 views

Rewrite C# class in F# result in half performance, any suggestion?

This is my c# class takes 2.6s class Snake { readonly Symbol _mySymbol; readonly int _multiplier; readonly int _hit; readonly int _payout; readonly Snake _bestSnake; ...
4
votes
1answer
80 views

How to refactor this groupby alike method but with index?

I have got such 2d jagged array (row is 1st dimension, column is 2nd dimension, bottom to up, left to right) 0 0 b b b c 0 0 h g g c 0 0 h a a c 0 0 f f d d 0 ...
3
votes
3answers
164 views

How to improve this array manipulation function?

The function takes 2 arguments: array: int[], cap: int Members would be ranged from 0 to cap. e.g. array = [0,0,0,2,6,3,0,4,2,4,0] cap = 6 The return value is a new array of same length based on ...
3
votes
2answers
277 views

Immutable pure data classes with public setters on properties

I'm putting together some classes as a model for some information (that I'm currently pulling from a website). The classes are implemented in C# - because in the current version of F# there are no ...
3
votes
1answer
383 views

Review an asynchronous/message-oriented library actor

I'd like to get input on a F# actor that coordinates receives around a blocking message buffer. The actor is a piece of code that continuously tries to fetch messages from Azure Service Bus. (* ...
2
votes
1answer
95 views

My implementation of lexicographic permutation in F# is 3x slower than C#?

Can someone help me with the following micro optimization for the f# code for lexicographic permutation? I have code in C#, which runs 0.8s in x86 and x64. As a learning practice, I translated it ...
2
votes
2answers
207 views

Using a Function to emulate F# Match in C#

So this was inspired by: this question But doesn't actually answer it: What do you think of: public class Case<TRes> { public Case(bool condition, Func<TRes> result) { ...
2
votes
1answer
611 views

Symbolic derivative in C#

I have translated the following F# code to C# and would appreciate constructive criticism. This code computes the symbolic derivative of the expression f(x)=x³-x-1: type Expr = | Int of int | Var ...