Questions tagged [f#]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
52 views

F# thumbnail Scraper

Thumbnail Scraper I'm a C# programmer learning F#. For my first program I created a console youtube thumbnail scraper. It parses command line arguments with argu and then downloads the thumbnails, ...
user avatar
3 votes
0 answers
189 views

Command line wordle

I am seeking a review of my command line wordle game. Having only recently started exploring functional programming, I expect that there will be no shortage of areas to improve. This is my first ...
user avatar
0 votes
0 answers
55 views

Early exist fold implementations in F# with a high degree of similarity

I've been writing a bunch of helper functions lately, all revolving around the concept of an early exit fold (which is a bit like unfold, i.e. you can control when the looping ends but you pass a list ...
user avatar
  • 1,101
0 votes
0 answers
90 views

Project Euler 1, 2 and 3: Functional Programming style using F#

After doing about 50 Project Euler problems in my "native" language (C#) I decided to redo some of the problems I did many years ago in F#, as it's a language I always want to give a go. ...
user avatar
2 votes
1 answer
108 views

Sieve of Eratosthenes in F#

after looking at the pseudocode for the Sieve of Eratosthenes on wikipedia I tried implementing a similar version using F#. The code runs just fine, that is, it returns all prime numbers up until a ...
user avatar
2 votes
0 answers
75 views

Download and parse XML data from a URL every minute with F#

The purpose This code is intended to achieve the following goals:- Create a hard coded list of lifts, this is pretty static and I add some extra info so I'm ok with this being in the code but I may ...
user avatar
0 votes
1 answer
56 views

Cardinal to ordinal numbers in F# code reuse

I've been experimenting with the F# Bolero environment to learn F# a bit and I was trying to get the hang of pattern matching by generating ordinal numbers (1st, 2nd, 3rd, ...) from cardinal numbers (...
user avatar
2 votes
1 answer
66 views

F# simple monoalphabetic cipher code implementation

I am a new F# programmer, and a student in a security class. As part of my notes, I wrote a small implementation of a monoalphabetic cipher as follows: ...
user avatar
2 votes
1 answer
61 views

Retrying failed calls to a crypto exchange

This code represents logic used to retry failed calls to a crypto exchange: ...
user avatar
  • 173
2 votes
3 answers
95 views

How to refactor the boolean logic of this F# function?

I have a list of path I want to filter out. I want to keep only paths matching a specific pattern and remove all paths matching another specific pattern. To achieve this I pattern matched on each ...
user avatar
  • 561
-1 votes
1 answer
87 views

What would be this best way to show that my function can accept some specific numbers as input? [closed]

I am writing a credit card generator. I have method GenerateVisa() who will return either a 13 or 16 numbers string. This is the default value but GenerateVisa can ...
user avatar
  • 561
3 votes
1 answer
129 views

Print each word of a sentence in a new line

this is my first F# program, very simple concept but took me a few minutes to get it. I'm new to functional programming so I'd appreciate if you could have a look ...
user avatar
  • 131
0 votes
1 answer
49 views

Downloading multiple log files

This code succeeds in downloading log text files from multiple URLs. Can this be made more efficient? ...
user avatar
1 vote
2 answers
411 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 ...
user avatar
  • 561
1 vote
1 answer
56 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 ...
user avatar
  • 507
0 votes
1 answer
54 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: ...
user avatar
4 votes
1 answer
123 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. ...
user avatar
  • 1,101
1 vote
0 answers
126 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 ...
user avatar
7 votes
1 answer
157 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 ...
user avatar
  • 1,101
5 votes
1 answer
139 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 ...
user avatar
3 votes
2 answers
100 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 ...
user avatar
6 votes
1 answer
110 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 ...
user avatar
  • 201
4 votes
1 answer
196 views

CodeWars Deodorant Evaporator

How can I make the solution to this https://www.codewars.com/kata/5506b230a11c0aeab3000c1f/train/fsharp more "functional"? ...
user avatar
4 votes
1 answer
95 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 ...
user avatar
3 votes
3 answers
157 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 ...
user avatar
  • 1,101
2 votes
1 answer
79 views

F# Array with tuples or Map

I have a sample code and some question. Simple type property ...
user avatar
3 votes
0 answers
150 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: ...
user avatar
2 votes
2 answers
100 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 ...
user avatar
  • 1,364
2 votes
1 answer
134 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 ...
user avatar
  • 284
3 votes
2 answers
97 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 ...
user avatar
4 votes
1 answer
618 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 ...
user avatar
3 votes
0 answers
73 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 ...
user avatar
2 votes
1 answer
80 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 ...
user avatar
3 votes
0 answers
166 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 ...
user avatar
3 votes
1 answer
219 views

Simple queue on F#

...
user avatar
4 votes
1 answer
94 views

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

I have the following code: ...
user avatar
  • 173
0 votes
1 answer
110 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#: ...
user avatar
2 votes
0 answers
84 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 ...
user avatar
3 votes
2 answers
94 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 ...
user avatar
1 vote
0 answers
44 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. ...
user avatar
4 votes
0 answers
324 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 ...
user avatar
  • 1,101
2 votes
1 answer
228 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: ...
user avatar
  • 1,101
6 votes
2 answers
274 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 ...
user avatar
  • 1,101
1 vote
0 answers
68 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: ...
user avatar
1 vote
1 answer
70 views

F# Simple message reader using TCP

I have a review request about this part of the code: ...
user avatar
4 votes
1 answer
128 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 ...
user avatar
4 votes
1 answer
219 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 ...
user avatar
3 votes
0 answers
209 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 ...
user avatar
6 votes
1 answer
76 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: ...
user avatar
  • 1,101
4 votes
2 answers
213 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 ...
user avatar

1
2 3 4 5
8