We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [f#]

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

Filter by
Sorted by
Tagged with
3
votes
0answers
34 views

Flashcard Website

In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome. First, some pictures of ...
3
votes
0answers
59 views

Simple queue on F#

...
3
votes
0answers
38 views

F# method to insert, update, or delete events in a dictionary

I have the following code: ...
0
votes
1answer
52 views

Asp.net middleware [closed]

This code is asp.net core middleware written in f# and called from c# for a blazor server-side app. How can this be made more efficient if any in regards to the async code. F#: ...
2
votes
0answers
75 views

Sanitize input for a “robot on a grid” kata

I have the following piece of code which is FSI tested and works. However, I want to trim it as much as possible (not only the comments, which are there for my own future reference) and make it as ...
3
votes
2answers
80 views

Query a product from a list of brands

I am quite new to F# and just wrote my first program. It checks if the query exists in the brand list and returns the matching brand. Query is the string you are searching for in the brand list. So ...
0
votes
0answers
30 views

F# and UDP server/client

I have a simple UDP client/server code looke like: ...
1
vote
0answers
37 views

Photo rename by Exif date and group into folders with a threshold

I wrote this tiny F# project yesterday, but I am a bit rusty and I would like to know if there is anything I can refactor and make more elegant. ...
2
votes
0answers
33 views

F# XML Generation in .NET Core: XmlSerializer or XmlProvider

I am working on SEPA XML generator in F#. I developed two solutions that are roughly equivalent, one relies on the XmlSerializer while the other relies on ...
1
vote
1answer
49 views

Idiomatic way to write proper F# (x)unit + fsunit tests?

I am writing some unit tests using XUnit in F# and I am wondering what is the most idiomatic way in the F# sense to write them. Let's start a simple case: ...
6
votes
2answers
180 views

Asynchronous IBAN API with validation

I am working on an iban api which is about saving the iban of some members after (iban validation) in a database. The code is split between Domain (entities, behaviour for iban validation), Database ...
1
vote
0answers
45 views

F#, Timer and propperly removed ElapsedEventHandler

I have a simple method that receives messages from bus, builds response and send it back, and it looks like: ...
1
vote
1answer
57 views

F# Simple message reader using TCP

I have a review request about this part of the code: ...
4
votes
1answer
72 views

Binary Trie in F#

I have this little exercise writing a binary trie in F#. In C# it can be done in few lines, but here it became more complicated than I had expected (especially the ...
4
votes
1answer
72 views

Convert to and from variable length quantities

As part of small MIDI library i've implemented the conversion of a VLQ (variable length quantity) for byte[] -> bigint and ...
3
votes
0answers
92 views

Async in Railway Oriented Programming in F#

In F# the Railway Oriented Programming pattern can be implemented synchronously using the Result<'t,'terr> type as result value for functions, so they can be ...
6
votes
1answer
55 views

F# pattern matching to determine the state of a bank account based on past events

I am writing an event sourced system in which I need to have the state based on the events that already occurred for a given bank account. The events are defined such as: ...
5
votes
2answers
120 views

Tcp server messenger awaiter in f#

Hi I have a simple tcp server, and that server receives messages with specific length so basically i need to wait for TcpClient to fill buffer with that amount of data, and it works. But I am not ...
2
votes
0answers
57 views

A simple functional F# wrapper for EasyNetQ

This is my first attempt at creating a small module to wrap the .NET library EasyNetQ in F# to make it more functional. I am pretty new to F# and I would like to get feedbacks on everything: types, ...
4
votes
2answers
91 views

F# wrapper to generate SHA256 signature for a file

I've created the following module to allow me to generate a SHA256 signature for a file. (In real life this is used to verify an image file hasn't been amended). The cut down code looks like this: <...
4
votes
2answers
135 views

Roman Numbers - The Functional Way

Yet another exercise in converting values between the decimal and roman number systems. I have tried the functional way. Any comments are welcome - but I'm especially interested in answers focusing ...
3
votes
1answer
43 views

Concise way of “updating” element in nested collections

Imagine simple game: ...
2
votes
1answer
60 views

F# parse data and calculate sum

I decided to play with F# and found simple task on Codewars. The task is sounds like "Calculate Sum/Mean/Avarage for selected City". I decided to calculate only Sum. My solution is horrific. I would ...
2
votes
1answer
63 views

Project Euler Problem #102 in F#: counting triangles that contain the origin

I've recently decided to get into functional programming with F#, and decided to learn the language through Project Euler. The following is my implementation of problem 102: Problem: Three ...
3
votes
1answer
236 views

Convert bitcoin value based on exchange rate from JSON API

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin. ...
2
votes
0answers
42 views

Creating idiomatic and efficient method to stream large JSON file

The purpose of the code is to efficiently stream JSON items from a large file. I am wondering if this is efficient and decently idiomatic. Not sure how I could eliminate the while loop either. ...
4
votes
1answer
57 views

Analyzing spoke overlaps during rotation: Round 2

Round 1: Analyzing spoke overlaps during rotation I previously posted this question, but I've changed a lot of the code since then. There was a mention of the previous being a bit mixed up, and ...
6
votes
1answer
58 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 ...
6
votes
1answer
77 views

Verifying that three cards make a “Set”

The game of Set involves cards with four properties: number, symbol, shading, and colour. Three cards make a "Set" if the property is either all the same or all different across the three cards, for ...
1
vote
0answers
36 views

Blockchain implementation in F#: Wallet

Introduction This is Part 3 of my F# blockchain implementation. Previous parts: Block and Blockchain Transactions Code In this part I am implementing a wallet functionality. The code is based on a ...
3
votes
2answers
520 views

Advent of Code 2018 day 1 part 2: find the first aggregated number that occures twice

I am using the coding puzzels of https://adventofcode.com for improving my F# skills. Problem: Day 1 Part 2: Starting with frequency 0, a list of numbers should be added successive generating new ...
8
votes
2answers
257 views

Conway's Game of Life F#

I am a C# developer learning F#. Would appreciate any suggestions on how this code can be improved. Main points I am interested in: Functional style of the code, absense of imperative style(C#) ...
1
vote
0answers
57 views

Blockchain implementation in F#: Transactions

Introduction This is Part 2 of my F# blockchain implementation. Previous parts: Block and Blockchain Code This time I am tackling transactions. The code is based on a JavaScript blockchain ...
2
votes
1answer
38 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 ...
5
votes
0answers
191 views

Creation of matrix with specific attempts at the end

What I want to do is build a Slay-the-Spire-like Map. As you can see in the following image, the map is splitted in ISteps and ...
5
votes
2answers
94 views

Encoding and decoding log entries in a Lossy Binary Format

One of the projects I'm working on requires logging a huge amount of information (basically, every function call). The problem is obviously that logging a lot of information has a few side-effects, ...
6
votes
1answer
270 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#. ...
2
votes
0answers
103 views

Lexer function to handle the '/' character

I'm writing a toy compiler, which is in a very early stage of development. The lexer contains the following block of code: ...
2
votes
2answers
107 views

Sorting a list into different bags according to predicate

I've just started with F# (I'm coming from a mostly OO background) and I'm looking for feedback on the code, particularly: is this the way F# code should be written like? have I overlooked an ...
5
votes
1answer
175 views

F# Idiomatic Log4Net Wrapper

I put together a log4net wrapper that more closely resembles F#-idiomatic logging functions. The basic idea is that there's a Log module that defines a set of 8 ...
2
votes
1answer
204 views

Roslyn analyzer, converted from C# to F#

I'm learning F# and for an exercise, I took a roslyn analyzer in C# and ported it to F#. In the excerpt below the GetParameterInfo function: takes in ...
4
votes
1answer
93 views

Async/Await Computation Expression

When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task<T> rather ...
10
votes
3answers
163 views

Generating image gauges from a value, min and max

One of the things I was recently investigating was the ability to generate "gauge" charts—that is, a chart which shows where a value stands within a range of values. As an example, if we know ...
5
votes
3answers
664 views

Implementing class equality/comparison in F#

I'm working on some book material on classes and interfaces in F#. My example is a latitude/longitude class: ...
4
votes
0answers
64 views

Hierarchy (Family Tree) Domain Model

I'm wanting to model a family tree in the F# type system. The basic requirements: A family tree is made up of family members A ...
5
votes
1answer
149 views

Simulating coin flips and plotting a histogram

I started playing around recently with F# and I find it quite elegant and succinct language. A common problem I like to solve in every language I start to learn is the coin flip problem, with the ...
2
votes
0answers
57 views

Business Rule DSL for Values in Domain-Driven Design

Following the patterns from the book Domain Modeling Made Functional, I am implementing a single-case union for the simple values in my domain model instead of using primitives. The union cases have ...
5
votes
0answers
335 views

Backtracking solver for n queens problem and knight's tour

Playing with https://ocaml.org/learn/tutorials/99problems.html#Miscellaneous-Problems I wrote a backtracking solver for the n queens problem, then the knight's tour, and realised I could generalise ...
4
votes
1answer
117 views

Lock-free Immutable ConcurrentQueue

Similar to the code review I posted last week for an agent-based immutable replacement for ConcurrentDictionary, I have also created an agent-based immutable ...
7
votes
0answers
97 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 ...