F# is a succinct, expressive and efficient functional and object-oriented language for .NET

learn more… | top users | synonyms

2
votes
1answer
34 views
1
vote
1answer
45 views

Basic templating engine in F# using F# syntax

I've been working on a rough idea for a templating engine (mostly as a learning project) using the F# syntax. How "correct" is my code in terms of being idiomatic F#? Are there F# features which would ...
6
votes
4answers
160 views

Splitting a sequence into equal segments

I need to split up a sequence into equal segments of a given size (yes, the last one may be shorter), and I'm trying to find an efficient and idiomatic way to do it. I have two versions of the ...
13
votes
2answers
511 views

First real-world F# application - how “good”/idiomatic is it? (long!)

After reading/watching various introductions and blog posts and some code here and there, doing a bit of the Try F# tutorial and starting to read "Real World Functional Programming", I felt I should ...
3
votes
0answers
61 views

Simple RabbitMQ client wrapper

After reading this question, I've realized that I can do a lot to improve the quality of my question, so I've edited this question quite a bit. I've been teaching myself F# in my spare time off and ...
7
votes
3answers
125 views

Poker Hands Kata in F#

I'm a F# newbie, and would like to share my implementation of the Poker Hands Kata problem to get some feedback. ...
7
votes
1answer
100 views

Hierarchical State Machine in F#

I appreciate any feedback on where I might alter or improve my code for this project. This is an old attempt at implementing a Hierarchical State Machine in F#. I'm from a C#/OO background mostly. ...
2
votes
1answer
86 views

Is this a good use of Async in F#?

I've hacked together some code to read the content from a sequence of files: ...
1
vote
0answers
38 views

What is the difference in these implementations? [closed]

While porting some C# to F# I wrote this code: ...
4
votes
0answers
106 views

F# and Rx code that throttles can it be done without ref cells (and possibly with active patterns?)

I'm basically redoing a piece of reactive C# code posted in SO code in F#, please, see below. The translation is fairly literal, I've just written the infinite loop as a recursive function and ...
5
votes
1answer
94 views

Read text from stream char by char

I've started learning F# and functional programming in general, but the code I wrote doesn't seems to be really functional. Could you take a look and say how to make it more as it should be in ...
6
votes
3answers
178 views

Functional approach to splitting list into sub lists

Here is my functional approach to split a list into sub lists, each having non-decreasing numbers, so the input \$[1; 2; 3; 2; 4; 1; 5;]\$ computes to \$[[1; 2; 3]; [2; 4]; [1; 5]]\$ The code ...
6
votes
1answer
117 views

Reading input from the console in F#

In the process of learning F#, I wrote this code that reads lines of input from the console and stores them in a list. As far as I can tell the code works correctly, but since I'm new to functional ...
3
votes
2answers
90 views

F# rectangle packing algorithm

I would appreciate it if someone experienced in F# and/or functional programming to look over my code. This is practically the first thing I wrote in the language so I'm sure it's filled with ...
1
vote
0answers
112 views

Review my F# Red Black Tree Implementation [closed]

I have written this implementation for red black tree. I also have some helper methods to verify whether the generated tree is really balanced or not. Looks good to me.... but I find that most of the ...
1
vote
1answer
118 views

Review my F# QuickSort Program

OK... last sort of the day and probably the most fun. F# is really awesome. ...
1
vote
1answer
93 views

Merge Sort Program

I have written the following program to implement merge sort in F#. Can you please review this and let me know how can I write this in the most functional way (also most efficient and concise)? In ...
1
vote
2answers
44 views

Review my F# BubbleSort Program

I have written this code for BubbleSort in F#. Can you review and let me know how I can do this in most functional way. ...
4
votes
2answers
49 views

InsertSort F# program

I have written this InsertSort program in F#. It works, but I am not very happy with it. ...
2
votes
1answer
68 views

Using types in F#

I've played with F# for over a year, but I've only recently begun tentatively using it for professional work. I'm concerned that my c-style OOP principles are blinding me to the advantages of a ...
4
votes
3answers
108 views

Improving F# conditional assignment with match expression

In my code I declared a dictionary to store various counters let counters = Dictionary<Type, int>() Later, I need to generate several labels using these ...
2
votes
1answer
90 views

parallel.For function

I am trying to add parallelism. The following function works. For testing purposes, calculating chunckLength is fine. However, when I allocate more cores, it seems ...
2
votes
1answer
122 views

Barnes-Hut implementation of the N-Body problem translated from F# to C#

I am after a peer review of a C# implementation of the Barnes-Hut algorithm which I have translated from F#. The F# version is the base for comparison, therefore the C# version is suppose to reflect ...
1
vote
2answers
143 views

Async querying SQL in IIS

...
2
votes
3answers
592 views

Project Euler Problem 7: Find 10001st prime number

I was able to complete the problem, but I would like to improve my code and make it more idiomatic. Here is the challenge description: Problem 7 - 10001st prime By listing the first six ...
3
votes
1answer
265 views

Coding Functional style taking longer time than its Imperative style

I wanted to try out F# so I decided to I converted a library file from c# to f#. I have done that successfully(thanks a you people in stackoverflow). At first I ported the code from c# to f#. Than I ...
6
votes
1answer
236 views

Discriminated-unions in C#

So I really want to have something similar to discriminated unions in C#. One way to do it is to use a visitor pattern, but it takes half a life to write all broilerplate code by hands. There is ...
2
votes
2answers
86 views

Recursive function refactoring help: occurrences of char in string starting at ith char

Just getting into functional programming and F# with the most appropriately titled Functional Programming Using F#. I wrote the following function definition for problem 2.4 but I'm thinking there's ...
1
vote
1answer
83 views

How to use pattern matching within curried function

I'm learning F# and I'm trying the following exercise (exercise 4.10 of Functional Programming Using F#). Declare an F# function prefix: ...
0
votes
1answer
166 views

F# solution to generic new() constraint limitation

Today I decided to get into F#. I watched this video and had a bit of fun doing some coding examples, I can see that it will be very useful for certain programs that I write. One thing that I was ...
4
votes
2answers
281 views

Learning F# - Porting C# Function to F#

I'm an advanced C# programmer learning F#. As an exercise I'm porting a function that calculates the check digit of a US ABA (routing) number. Here are 2 C# implementations: ...
2
votes
1answer
152 views

Improve this numeric solver for properties of geometric objects

I'm converting some C# code to F#. Basically it is some geometry classes that can have properties tuned by a numerical solver. I start with a discriminated union of type ...
7
votes
2answers
249 views

What's the most idiomatic way to call a function an arbitrary number of times with the previous result?

Basically I have a function of the type 'a -> 'a (an optimization function on a AST) and I want to call it (passing the previous result) until it returns the ...
2
votes
2answers
214 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 ...
3
votes
3answers
155 views

Idiomatic conditionals in F#

I'm learning F#, and even though I'm able to do whatever I want, parts of my code looks really bad. I would love to get some suggestions on how to improve a couple of functions involving some ...
1
vote
2answers
234 views

RGB Color Name Matching using Euclidean Distance (Improved)

The code below stems from work on a Euclidean Distance algorithm. The color table was simply a vehicle to test the algorithm. It is perhaps reinventing the wheel, however it is useful in itself. ...
2
votes
1answer
138 views

VB.Net interfacing with F# Euclidean Distance Algorithm

I testing F# code which calculates "nearness" of two N-dimensional points using a least square euclidean distance algorithm. The class library is written in F# and the calling will be from VB.NET. ...
4
votes
1answer
235 views

How to better format my F# code for readablility

I am choosing to learn F# for my own enjoyment. I am getting to the point where concepts of F# seem to be pretty easy, but understanding some of the whys and whens is a bit harder. Before I get into ...
2
votes
2answers
100 views

Using Types to Designing Domain

I am trying to model a domain of metrics for use in a BI application. I recently read the Designing with Types series, and felt that it could be useful, so I wanted to give it a try. What I'm not ...
0
votes
1answer
91 views

Perfomance and Other Improvements

I am trying to wrap my arms around all the digital files we have, so I thought I would organize all of our pictures and videos into folders named after dates. I'm learning F#, and this felt like a ...
1
vote
1answer
81 views

TimeSpan don't support years so how do I deal with it? Is there could be smarter solution?

explain: from start day till now I've got 7.7 mb size, how long it will be to make it 10 gb size ...
2
votes
3answers
398 views

How to improve this array manipulation function? [closed]

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 ...
3
votes
1answer
288 views

Better ways to implement Conway's Game of Life in F#

As I'm learning some F# along with functional programming, I managed to implement the rules for Conway's Game of Life but I'm not sure if I can improve some of its parts. For example, the neighbours ...
4
votes
1answer
92 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) ...
3
votes
1answer
430 views

How to improve this unblock me / rush hour solver without any major change in search algorithm?

This is my first complete program written in F# (I was from C# and occasionally do interop) And I believe there are quite a few places I didn't tackle well in terms of coding practice. Problem ...
4
votes
1answer
422 views

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

This is my c# class takes 2.6s ...
4
votes
1answer
178 views

Is it worthwhile to simplify this code and how?

My original code is: ...
2
votes
2answers
411 views

simple stupid F# async telnet client

Did I write this code to correctly be tail call optimized? Am I forcing computations more than I need with !? Did I generally write this asynchronously correctly to ...
2
votes
3answers
143 views

Is there a better way of defining custom calendars?

I need to define custom calendars and, in particular, test a DateTime for being a holiday. My current code is shown below. Is there a more concise/better way of ...