Questions tagged [f#]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
106 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
285 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
2answers
765 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 ...
4
votes
1answer
1k views

Conway's Game of Life in F#

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

Unblock Me / Rush Hour solver

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. Unblock Me / ...
5
votes
1answer
756 views

Rewriting C# implementation of Snake class in F#

This is my C# class, which takes 2.6s: ...
5
votes
1answer
197 views

Determining directions for a 2D boad

My original code is: ...
2
votes
2answers
2k 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
172 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 ...
2
votes
1answer
240 views

Getting prices and volume

I'm learning F# and have a couple of routines much of whose functionality looks common so I am looking to refactor them together. Here are the routines (which for the record I lifted from elsewhere: ...
4
votes
1answer
326 views

Three implementations of mergesort in F#

I would appreciate some quick comments on this basic mergesort code. Am I missing a big block in the langage? First solution ...
5
votes
1answer
1k views

Path sum - Dijkstra's algorithm in F#

I'm learning F# and I've decided to solve Project Euler's Problem #81 with Dijkstra's algorithm. In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by only ...
3
votes
1answer
279 views

Euler 2 : Simple Fibonacci

I'm just starting to experiment with F# (from a C# background). I think I'm starting to get into the right way of thinking, but this code still seems pretty awkward. Is there a better (more terse) ...
6
votes
1answer
3k 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: ...
7
votes
1answer
928 views

F# Djikstras shortest path implementation

I'm just getting my feet wet with F#, by implementing some simple algorithms. First up: Djikstras shortest path. There is one piece I've written in this code which confuses me as to why it works: the ...
2
votes
2answers
326 views

How can this functional implementation of Kadane's algorithm be improved?

Some time ago I posted on Stack Overflow an imperative C# implementation of Kadane's algorithm for finding a subarray with maximum sum. Then I considered implementing the same functionally in F# and ...
3
votes
1answer
1k views

Basic neural network

I just programmed a basic neural network in F# to learn the logical OR function. As I am very new to F# and especially functional programming, I did it the imperative way. And even tho it works, I ...
4
votes
1answer
620 views

String calculator in F#

This is some of my first real F# code ever. I have done a bit of reading and watched a few videos however. I chose to do a code kata for string calculator to try it out. The kata I was working on is ...
3
votes
1answer
699 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. ...
4
votes
2answers
883 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
2answers
496 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: ...
8
votes
1answer
676 views

Deleting from Red Black Tree in F#

Yes I'm very slowly making my way through Purely Functional Data Structures. So I went through the section on Red Black Trees. What he presents is amazingly concise, except for the fact that he didn't ...
6
votes
3answers
452 views

Is there any way to improve (shorten) this F# code?

I have a very good grasp of the syntax and features of F# as well as some of the concepts that mesh well with the language. However, I do not have enough experience writing it to feel comfortable that ...
10
votes
1answer
899 views

Approach to programmatically building hierarchical GUI components

At work I am developing an application using hand-coded Swing, and I've found that I have an easier time reading, writing, and maintaining hierarchical component creation using code blocks like: <...
4
votes
1answer
348 views

Processing a tab-delimited file with vertexes and ages

The following block of code needs to be as fast as possible as it likely to be called many thousands of times in a run. I am also conscious that my thinking style is leaning towards a more procedural ...
6
votes
1answer
739 views

Map implementation in F#

Just as a refresher I put together a simple Map implementation and I would love to get some feedback on it. ...
5
votes
1answer
405 views

How can I make this F# more functional?

I am currently learning myself a little F# and have written the following code to practice. The code uses the Mono.Cecil library to inject some IL at the start of every method in each .net assembly ...
10
votes
1answer
516 views

Getting the last date where a given week day occurred

I'm trying to learn a little bit about functional programming and as my tool I chose F# since I'm a .NET developer and the environment is more natural to me. In one of my pet projects I'm dealing ...