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
42 views

Downloading multiple log files

This code succeeds in downloading log text files from multiple URLs. Can this be made more efficient? ...
1
vote
2answers
83 views

What would be the idiomatic F# way to write optional parameters?

In the context of a library to generate random credit card, it would be nice to let the user the possibility to set some optional options on some cards. Lets take Visa. Two lengths are available: 13 ...
1
vote
1answer
43 views

Maintaining state while walking a tree structure

The following code creates a simple tree structure and then walks through the tree looking for node with the value 9 that appears after we have seen a node with the value 1 and a node with the value 4 ...
0
votes
1answer
32 views

How to apply multiple filters in one statement

While trying to grasp the potentials of the collection features in F#, I encountered this one: ...
5
votes
1answer
118 views

Handling bill cancellation

I'm trying to refactor the working code below which intends to handle bill cancellation, but doesn't seem "linear" enough. ...
1
vote
0answers
73 views

How to flatten the nested try-catch block in F#?

How to flatten the nested try-catch block in F# for the following code? I am using EF Core with F#. The nested is required because I need to Rollback the transaction if there are errors in saving or ...
7
votes
1answer
134 views

Refactoring of two command handler implementations with F# in the context of event sourcing

I've written some F# code to handle commands in the context of event sourcing which works along the lines below: Read Events from a specific event store stream Build the current state in the given ...
5
votes
1answer
123 views

Converting a float to a fraction as a string

I was inspired by this video by Matt Parker to use the Farey Sequence to convert a float into a string representation of a fraction, how did I do? How well did I follow F# workflow and patterns (I'm ...
3
votes
1answer
81 views

Simple Password Generator Feedback

This is my first major project in F#, looking for any critique on how I can make it more standard or more concise. Some things I feel like I could have done better are the command flag parsing and the ...
6
votes
1answer
92 views

First-time F#: A simple Rock Paper Scissors

This is my first F# program. It's a simple Rock-Paper-Scissors implementation. I am looking for feedback of all sorts, e.g. the choice of types (e.g. List vs Array), whether there are parts that could ...
4
votes
1answer
114 views

CodeWars Deodorant Evaporator

How can I make the solution to this https://www.codewars.com/kata/5506b230a11c0aeab3000c1f/train/fsharp more "functional"? ...
4
votes
1answer
71 views

Return early with Error from Sequence mapping

I have put together this f# code in an attempt to solve the following problem Given a mapping operation that may not be able to return a value Cease mapping over the remaining items of a sequence if ...
3
votes
3answers
137 views

Idiomatic F# for iterating a seq and mapping whenever changes occur on a given selection

I've written a function that takes a sequence and check for every item in that sequence whether the current value a selection (obtained with a selection function) is different (or on the first ...
2
votes
1answer
41 views

F# Array with tuples or Map

I have a sample code and some question. Simple type property ...
3
votes
0answers
134 views

N-Queens Puzzle

The N-Queens puzzle can be solved in many ways. One is by a depth-first-search backtracking algorithm. Below is my generalized version using mutual recursion: ...
2
votes
2answers
91 views

Advent of Code 2019 day 2 in F#

I sped through the 5hr F# pluralsight course this week-end and thought I'd sement my learning by going through as many Advent of Code puzzles I could with this new learning. However, already on day 2 ...
2
votes
0answers
93 views

“Rock, Paper, Scissors +” in F#

During a discussion in a development chat, a user suggested to another (in the context of C# originally), UserA: Challenge: Create an implementation of RPS, and then show how it can be extended to ...
3
votes
2answers
96 views

Solving the game Set in F#

I was playing the game Set online, and thought it would be a good exercise to write an F# script to find all of the sets for me. The rules of set are as follows: A SET is 3 cards for which each ...
4
votes
1answer
330 views

F# Binary Tree and Tree Traversal

So for an side exercise on exercism I implemented a BinarySearchTree. I was confident in implementing the creation of the binary tree. But I'm very unsure about the traversal of the tree. So I came ...
3
votes
0answers
52 views

Functional Dependency Injection Abstraction

The F# web-development framework Giraffe supports a functional style of Dependency Injection using a form of the Reader monad, as explained in this GitBook. I would like to use this pattern more ...
2
votes
1answer
77 views

Assigning jobs in a functional style

I'm new to F# and functional programming in general (coming from an object oriented background). I just wanted to get some criticism on an algorithm for assigning jobs to crew members. I want to be as ...
3
votes
0answers
98 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
1answer
147 views

Simple queue on F#

...
4
votes
1answer
76 views

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

I have the following code: ...
0
votes
1answer
92 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
82 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 ...
4
votes
2answers
88 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 ...
1
vote
0answers
39 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. ...
3
votes
0answers
187 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
148 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
261 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
55 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
64 views

F# Simple message reader using TCP

I have a review request about this part of the code: ...
4
votes
1answer
86 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
195 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
149 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
69 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: ...
4
votes
2answers
185 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 ...
3
votes
0answers
123 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
177 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
199 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
44 views

Concise way of “updating” element in nested collections

Imagine simple game: ...
2
votes
1answer
82 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
80 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
241 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
44 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
58 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 things ...
6
votes
1answer
59 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
86 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
41 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 ...

1
2 3 4 5
8