Questions tagged [f#]

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

Filter by
Sorted by
Tagged with
6 votes
1 answer
546 views

Blockchain implementation in F#: Block and Blockchain

Some time ago I started writing a blockchain implementation for learning purposes. I used this article as reference. Originally I wrote the code in C# but recently I have rewritten everything to F#. ...
Kapol's user avatar
  • 324
5 votes
2 answers
231 views

Constructing a simple tree with ASCII in F#

This is just a basic HackerRank challenge I was working on to better understand F#. Its purpose is just to print a tree that has a straight 'trunk' of \$n\$, splits into 2 branches which diverge to \$...
C Bauer's user avatar
  • 361
3 votes
1 answer
321 views

F# implementation of the A* algorithm

This is my first attempt at writing something useful in F# and in a functional way in general. I would appreciate if you could point out any issue, even details, as I'd like to put all the bad habits ...
Stud's user avatar
  • 786
25 votes
2 answers
2k 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 ...
TeaDrivenDev's user avatar
11 votes
1 answer
492 views

American Checkers

I am implementing the logic for a Checkers game in F#. I am writing my code in a library so it can be called from any UI provider, and am trying to do it in good FP style. I currently have the ...
user avatar
10 votes
2 answers
394 views

You can't sink me

Here is a Battlehips game in F#. Now, before you start jumping up and down on my code, please understand that, for all its awesomeness, F# has a serious limitation: Its compilation is linear, and the ...
user avatar
8 votes
2 answers
732 views

Caesar cipher in F#

I'm trying to broaden my horizon by learning functional programming (coming from OO, specficially C#). For this, I'm implementing some small problems to get a feeling for the language. One of my first ...
germi's user avatar
  • 488
7 votes
0 answers
116 views

Agent-based Immutable Map

I am in the process of removing the last few pieces of mutable state from an F#-based distributed system. Some of the remaining mutable state is a ...
Aaron M. Eshbach's user avatar
7 votes
1 answer
122 views

World's worst Christmas tree

Inspired by this question, I decided to grow my own fractal tree. The problem is: given an integer \$n\$, \$0 \leq n \leq 5\$, print the \$n\$th iteration of the fractal tree. The tree is probably ...
mjolka's user avatar
  • 16.2k
7 votes
1 answer
580 views

F# inventory system

To learn F#, I've implemented this very simple inventory system. While I'm proud that that it's my first program, and that it works, there are still a few areas that I'd like tips on, namely these: I ...
Ethan Bierlein's user avatar
7 votes
1 answer
107 views

Streaming a Pin functionally(ish)

Earlier today I wrote a question (Validating a StreamingPin) and I thought it was a good idea (apparently I was the only one who thought so, but whatever), so I proceeded further with it and developed ...
Der Kommissar's user avatar
6 votes
1 answer
70 views

Analyzing spoke overlaps during rotation

For a personal project that I've recently started I have to analyze the rotation of two shapes with sets of spokes, where the spokes are evenly-spaced, and split into a given number. That is, if I ...
Der Kommissar's user avatar
6 votes
1 answer
433 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 ...
Mongus Pong's user avatar
5 votes
1 answer
454 views

RSS Parser for Blog Feed

I'm building an RSS feed parser so, later, I can retrieve recent blog posts on my word press blog and display recent posts on my other website. This code isn't intended to implement the full RSS spec. ...
RubberDuck's user avatar
  • 30.8k
5 votes
1 answer
339 views

The Functional FizzBuzz Kata

I run a coding dojo at work. For one session I'm to showing that you can use a kata to get into a new language. I'm using the FizzBuzz Kata to to show F# (and JavaScript) because it is short. The ...
Paul Spencer's user avatar
5 votes
2 answers
379 views

Project Euler 3: Getting the largest prime factor of a number

I'm looking for some general feedback on my solution to Project Euler challenge 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? <...
Overly Excessive's user avatar
5 votes
3 answers
1k views

Partitioning a list in F# based on whole group characteristics

I only started programming in F# yesterday, so I've not yet discovered what idiomatic F# actually looks like. The first task I set myself required partitioning a list into smaller lists but where the ...
Scroog1's user avatar
  • 508
5 votes
1 answer
148 views

Tally Calculator for Baloot in F#

This is a tally calculator for the Saudi card game Baloot. As in, they're a set of functions so that the user would provide their winnings at the end of a round (card captured, projects declared, etc) ...
asibahi's user avatar
  • 927
5 votes
1 answer
2k views

Battleship Game

Inspired by this question, I went on with the following version. My goal was to focus on pure functions, to avoid mutable variables and to be strictly functional. I have ignored the computer player ...
user avatar
4 votes
1 answer
190 views

Transform Bitmap object into jagged array of RGB tuple values

I've been working on this module with the assistance of codereview, and based on the responses and my own research, this is my project so far. The goal behind the code is that it starts with a .NET ...
Ken's user avatar
  • 653
4 votes
1 answer
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 ...
viniciushana's user avatar
4 votes
2 answers
634 views

Reverse Polish Notation in F#

In my question to learn F#, I've decided to get one step closer to creating a programming language, and implement this simple Reverse Polish Notation "interpreter" of sorts. It does not allow for ...
Ethan Bierlein's user avatar
4 votes
1 answer
315 views

Reporting the highest satisfied poker hand in F#

I'm learning F# by doing various small projects. One of them is a problem where the program reads Poker hands and rates them. It's Texas Hold'Em, so for each player it tries every five card selection ...
Grubl3r's user avatar
  • 205
4 votes
2 answers
210 views

Compact game of life implementation

I am learning F# and implemented Conway's Game of Life as an exercise (There are also other implementations on CodeReview). I have tried to forget all my object-oriented background and practice "...
JanDotNet's user avatar
  • 8,538
3 votes
1 answer
302 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) ...
Davin Tryon's user avatar
3 votes
2 answers
521 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: ...
Frames Catherine White's user avatar
3 votes
1 answer
205 views

Refactoring while-do into tail recursion with F#

I have a while-do loop nested inside a while-do loop in my program, due to it needing to iterate in two dimensions through an array of arrays, and originally my loop looked like this: ...
Ken's user avatar
  • 653
3 votes
1 answer
487 views

Transforming a byte array into an array of byte arrays with F#

This code is intended to be used with an image manipulation library that I'm working on, and the goal is to take the raw byte[] data from an image, and transform it into a 2D array where each position ...
Ken's user avatar
  • 653
3 votes
1 answer
191 views

Locating a bitmap inside another (larger) bitmap with F#

This is my firstish (heavily rewritten) go at the completed project that I've been working on with CodeReview assistance, so further advice is appreciated! See here, here and here for the past history ...
Ken's user avatar
  • 653
2 votes
1 answer
321 views

Summations and products in F#

I was bored, and looking to do something that involved anonymous functions, and it was suggested by @Quill, that I create a summation function. I decided to also include a product function as well to ...
Ethan Bierlein's user avatar
2 votes
1 answer
50 views

Connect elements of a list to elements of an other list using a two-dim array

Story: I build a kind of labyrinth. This labyrinth is divided in seven steps. You start with the first, then second, and so on to the seventh. You cannot go back to a previous step. Each step ...
Maxime Recuerda's user avatar
1 vote
1 answer
219 views

Load bitmap object data into array of byte values

I'm building this as part of a larger class to rapidly search for smaller images inside larger images. This is my first serious F# project so comments especially concerning style and organization are ...
Ken's user avatar
  • 653
1 vote
1 answer
154 views

SalesTax challenge

This is the same problem, but I decided to do it using F#. I'm just interested in how I can improve it. ...
Alexan's user avatar
  • 371