Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [f#]

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

3
votes
0answers
104 views

F# Observable.subscribeWeakly implementation

In this SO question I needed an observable subscription function that can be used kind of like Observable.subscribe, but that does not keep a strong reference to ...
8
votes
2answers
108 views

Wordpress RSS Parser

Follow Up to my earlier question. This is an RSS Parser intended only to parse the feed Wordpress provides (and even then, only what I actually want to display on my website). ...
5
votes
1answer
118 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. ...
3
votes
0answers
101 views

Concurrency using immutability

I was watching the following video about software transactional memory(using a package that maintains an access log). At the moment I am trying to learn about concurrency with shared memory and ...
1
vote
0answers
113 views

Is This F# Recursive Example Tail Recursive?

I have a payment/lockbox file archiving utility that is called several times per day and with different parameters depending on the files that need archiving. I know I can flatten ...
2
votes
2answers
47 views

Minimise function with single minimum and no maximums

I'm learning F#. I wrote a function to minimise a function with a single minimum and no maximums. At the bottom I test it on Math.Cos. What do you think? I've wrote it pretty much as I would in an ...
4
votes
1answer
119 views

Counting letter frequencies from an input file

Out of pure curiosity, I decided to create a short F# script to calculate the letter frequencies based on the input file. Everything works smoothly and as I would expect. My questions regarding my ...
0
votes
1answer
37 views

Questions on F#'s loop and cont [closed]

The following tail-recursion example is taken verbatim from Chris Smith's Programming F# 3.0. If this is not the appropriate forum for this post, I will gladly move the post to the appropriate place. ...
5
votes
1answer
228 views

Functionally find the index of the minimum value in an array

I come from a C#/JavaScript/TypeScript background and am learning F# by implementing fundamental algorithms. This is finding the minimum value in an array: ...
2
votes
1answer
429 views

Implement array element swap in a functional language

Sorting algorithms involve swapping element positions in an array. This is my implementation of swap: ...
2
votes
2answers
68 views

Immutable recursive binary search of a generic array

I am new to F#. Is the following code, which represents about three hours of work, a canonical way to achieve binary search? If not, how can it be improved for readability and maintainability? ...
5
votes
1answer
82 views

Learning F# with Prime Factorization

In my quest to learn F#, I implemented Prime Factorization. First, the code: ...
5
votes
2answers
207 views

Immuitable recursive linear search of an array of string

I am new to F#. Is the following code, which represents about three hours of work, a canonical way to achieve its goals. If not, how can it be improved? For instance, can we provide a default value ...
7
votes
2answers
433 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 ...
4
votes
1answer
64 views

Calculator for magic item creation in RPG

I have created a simple calculator that will assist in creating magic items from the tabletop RPG Pathfinder. Here are the full requirements, and if you want a more concise version, here is a player ...
3
votes
1answer
121 views

Parsing command line arguments

Usage: ...
4
votes
1answer
185 views

Searching files in directory with various filters

Requirements Note: the requirements are invented by me for practicing functional programming. Functional Requirements Given a directory, all files below the directory (and its sub directories) ...
1
vote
1answer
414 views

F# binary reader

I've written a fairly simple script in F# which reads structured data from binary. I've avoided using the built-in .NET BinaryReader class because it's stateful in that it maintains its index in the ...
6
votes
1answer
100 views

Reading numbers from console until input isn't a number

I want to read N numbers (Nmax = 100) from console into a list. N is not known, but the first input that is not a number may break the reading process... However the solution should be as simple as ...
4
votes
2answers
524 views

Event sourcing using functional programming

Is this a satisfactory implementation of event sourcing using functional programming? ...
3
votes
2answers
181 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 "...
1
vote
0answers
127 views

Simple INI and command-line parsing, functional programming edition

I'm in the beginning stages of rewriting the model layer of my VBA Sync Tool in F#, to better learn functional programming. So far I've defined: A public ...
5
votes
0answers
266 views

A* Algorithm in F#

Inspired by this post I looked up A* on wikipedia and went on with my own implementation as seen below where I try to mimic the pseudocode on Wikipedia but in a recursive manner. I would like any ...
4
votes
1answer
95 views

Pool Checkers with AI

I recently added Pool Checkers to my Checkers game. My main concerns are about how I manage calling the correct variant in my PublicAPI functions. Because this is ...
3
votes
0answers
89 views

F# implementation of the A* algorithm round 2

This is my second attempt at implementing the A* algorithm using F#, the first one is here. What I changed: I removed the Node class and added two records named ...
3
votes
1answer
150 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 ...
0
votes
1answer
128 views

Adding jokers to a deck of cards

I originally had the following code: ...
3
votes
3answers
108 views

F# program to generate a Map of substrings frequencies

I wrote the following F# program that takes an input txt file and create a Map that contains all possible substrings of size N and their frequency in the file. In other words if I call the program ...
5
votes
1answer
114 views

Compute a value (and update a CSV record), based on prior value

The F# code below embodies the two specific questions I have. It is part of a working transformation utility, the entirety of which, including sample data, is in this gist: http://bit.ly/2i3kUwF. ...
10
votes
2answers
333 views

American Checkers with AI

This is the third question in the series. Number 1 had most of the official two-player rules implemented, and Number 2 was the basic UI. This one has the complete two-player rules implemented, an AI ...
6
votes
2answers
230 views

Navigating a bounded 2D list (Advent of Code, Day 2: “Bathroom Security”)

I'm trying to solve the following Advent of Code problem in F# for practice. Description of problem (can be found here): Basically, there's a 'key pad' that I need to figure the combination to. To ...
11
votes
1answer
375 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 ...
1
vote
1answer
726 views

Wild and changing business rules implemented with functional programming

I attempted the Business Rules Kata. Here's a video overview. However, I am not confident that going functional is a good strategy for the following objective: How can you tame these wild business ...
6
votes
2answers
96 views

Probabilistic Matrix Inspection - Suggested by a paper, implemented by me

I have read this paper and I actually found it interesting. This is an attempt to implement the proposed algorithm. I would like to know: Is my algorithm correct by what is discribed in the paper? ...
2
votes
1answer
102 views

Insert Tree in F#

Can this be improved, or made more concise? ...
2
votes
2answers
194 views

F#unctional Immutable Trie (Prefix Tree)

I've created the following implementation of a trie in F# as an effort to learn the language. I would like to know what could be done to make it more idiomatic. Any other pointers are welcome as well. ...
4
votes
1answer
152 views

Word splitting / text parsing with consideration for quotes

Is the MoveNext operation inefficient here? I really just want to increment an index. Originally, I had a mutable variable locally in ...
1
vote
0answers
85 views

MailboxProcessor and prioritized messages

I'm trying to create an agent that holds on to Data and does further work with it upon receiving the Work message. ...
4
votes
1answer
141 views

Print diamond of any size

I'm trying to print a diamond of asterisks of an arbitrary size. I'm new to F#, so I'm interested in virtually any feedback, but especially adherence to idioms, convention, and functional orientation. ...
2
votes
1answer
253 views

F# Active Pattern with Poker and Playing Cards

From this question and John Palmers answer about active pattern I discovered a gap in my knowledge about F# and took the challenge to code me into some level of understanding this technique. The ...
4
votes
1answer
240 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 ...
3
votes
3answers
103 views

Printing a table

I have this recursive function that I made which prints a table, but I really think my current solution is really ugly. Does anyone have an idea as to how I can improve my solution? I'm trying to ...
1
vote
2answers
296 views

F# Insertion sort

I made a simple insertion sort in F#, it uses a tail recursive shift function that attempts to shift an element in a list until it is in the right order. Would like ...
7
votes
3answers
151 views

Doing an ROP style bind for two functions on the same input in a pipeline

I am working on understanding Railway Oriented Programming (Scott Wlaschin style) in F#. In my example I want to create a pipeline which does some calculation, applies two different functions to the ...
4
votes
2answers
38 views

Implement total savings function on a record type

the TotalSavings() function on the record below has a code smell that I can't exactly detail. Is there a more readable alternative for implementing this function on a record type? ...
7
votes
1answer
95 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 ...
14
votes
1answer
327 views

Grand Chess domain model and helper functions

So I am trying to write, essentially from a blank slate, a program that plays Grand Chess. In short, it is a chess variant that is played with two extra pieces, on a 10x10 board, no castling, and ...
5
votes
1answer
685 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 ...
3
votes
1answer
147 views

hl7 parser with fparsec

I have a little experience working with .hl7 data (format for transmitting health data), so I decided to try and write an .hl7 parser using fparsec. A standard .hl7 segment is a single line with: ...
10
votes
2answers
263 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 ...