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

learn more… | top users | synonyms

3
votes
0answers
26 views

Async.sequence implementation

I have a simple implementation for "Async.sequence" (the name came from here), but I would like someone to review it for performance, tail call optimization, and ...
5
votes
1answer
50 views

Recursively traverse directory tree and print all files

I want to build a small console program, that for given directory, will print (for now) all files inside that tree. Here is an F# script that I came up with: ...
4
votes
2answers
54 views

F# function to concatenate some DSL scripts with indentation

I'm rather new to F# and functional programming. I wrote the following method to concatenate some custom dsl scripts. The function works are expected without errors. I wanted to know if there was a ...
6
votes
2answers
115 views

Recursive implementation of a zip function in F#

I'm learning F# from Tomas Petricek's "Real-World Functional Programming" book. As suggested at one point in the book, I started implementing a zip function using a ...
5
votes
1answer
45 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) ...
4
votes
1answer
62 views

Divide number by factors

I'm learning F#. The code below gets a number e.g. 100 and list of factors and should divide that number by the factors without any rest. (There is an actual code I've got in C#, but this is F# port). ...
2
votes
1answer
131 views

K-Means Clustering - F# Learning Challenge

Inspired by this blog I went on implementing my own version as a F# learning challenge. It turned out to be quite different than the original (but somewhat faster for large samples). The first code ...
3
votes
1answer
46 views

IsImageUrl extension method written in F#

I'm a newbie to F# and so I've written a small extension method library to practice the language. The extension method attempts to determine if a url string is for an image. I wrote the code as an ...
8
votes
4answers
127 views

Swap even/odd characters

I wrote some code to solve this problem https://www.hackerrank.com/challenges/string-o-permute which basically states: take an even length string and swap all the even indexed characters. For example ...
4
votes
1answer
54 views

Get a stock quote from a web page using F#

I want to extract a price for a single index fund, the price of which is available on dynamic web pages. Being new to this, my original idea was to download the single page of static HTML and get ...
4
votes
2answers
499 views

Web crawler in F#

I have been writing a web crawler in F# that downloads pages with stylesheets and scripts. Can somebody give me suggestions on improving this code, please? Would appreciate any feedback that could ...
1
vote
1answer
55 views

NFA and DFA implementation

Can you review my F# code and point out some insights about it? What I want to know, in order of relevance: Avoid so much common code between DFA and NFA. I want to make something more generic, ...
2
votes
1answer
241 views

Transforming XML to HTML with XSLT

I'm still learning from designing with types non strings by Scott Wlaschin. For my project I transform some XML to HTML with xslt. Because every filename can have side effects, they are stored in ...
2
votes
0answers
74 views

My Brainfuck interpreter in F#

I'm very new to functional world. I've written a simple brainfuck interpreter as my first F# program. What I would like to know: Am I using the right data structure for each situation? Is my code ...
3
votes
1answer
60 views

Compare performance of simple addition on one to many cores

I read recently that ENIAC originally was capable of 5000 additions per second. Naturally, I had to test my own laptop's capabilities and this became an instructive experiment in F#, which I suck at. ...
1
vote
0answers
31 views

F# logging agent with mailboxprocessor

I'm still learning F# and have written this logger agent I want to use in a project. How is the coding style? Especially the part with MailboxProcessor.Start ... ...
7
votes
2answers
76 views

Console input prompt loop in F#

I'm learning F#, starting with baby steps. Is there a way to write this code in a more succint way, while keeping the same semantics? Maybe by using a Seq or ...
2
votes
1answer
159 views

Parsing .PLY file using F#

I'm fairly new to F# and have written a program to parse PLY files - this is however done in an imperative way with mutable values and as far as I know that should be avoided in functional languages. ...
4
votes
2answers
48 views

Breaking lists into subgroups in F#

I'm starting to play with F# to do some data parsing and I was able to create a function to group an array of string into sub groups. The code looks like this: ...
5
votes
1answer
383 views

Anagram finder in F#

I've been learning F# for a month or so and I'm wondering how good my "functional" aspect of coding is. When I first started, I did this using an iterative approach with a lot of <- and mutables ...
4
votes
0answers
42 views

SqlDataConnection update method

I'm using Microsoft's SqlDataConnection type provider. However, the only way I've seen to update a row in the database is to use something similar to this where it updates mutable values: ...
3
votes
2answers
170 views

Heightmap generation using midpoint displacement

I am writing a program to generate a height map following the midpoint displacement algorithm (somewhat similar to diamond-square). I'm at the point where I have a recursive program that paints the ...
2
votes
0answers
69 views

Blocking Memory Queue

This is a FIFO blocking memory queue in F# to be used as a component in a logging library. ...
8
votes
2answers
106 views

Unit testing F# code without using an existing test library (MSTest, xUnit, etc.)

I know I can probably use MSTest (I'm under Linux without an IDE so maybe not?) or another unit testing library, but for a small project I decided to write my own unit tests without resorting to a ...
0
votes
1answer
25 views

Converting height map bitmap to json

This is my first F# program. It's a command line utility that takes a parameter containing a path to an height map bitmap and prints out this height map converted to JSON format. ...
4
votes
1answer
92 views

FizzBuzzWoof in F#

I'm learning F#, and have challenged myself to write a good functional implementation of FizzBuzzWoof. (The difference from "standard" FizzBuzz is that any number that either is divisible by or ...
5
votes
2answers
141 views

Dijkstra algorithm implementation in F#

I'm trying to implement Dijkstra algorithm in F# for finding the shortest path in a undirected tree using a heap. I've used the type PriorityQueue found here and the code can be found here. ...
1
vote
0answers
49 views

F# Cache manager

This is a port of a C# cache manager we use to F#, this is my first F# code, and I've tried to make it as idiomatic as possible. I would appreciate input on style, performance considerations,...
3
votes
1answer
87 views

Factory pattern in F# for a web scraper

I'm trying to learn F# by creating a little web scraper that will do custom scraping based on the url domain. For this, I need to create and select the correct kind of scraper. I figure I would use a ...
3
votes
1answer
111 views

Project Euler Q7 - 10001st prime

The problem is (source)... By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? This is my second attempt ...
1
vote
1answer
40 views

Create a collection of binaries with random set positions

I would like to create a collection of binaries with n set bits and total length should be between n and 31; also those set bits ...
2
votes
1answer
33 views
6
votes
1answer
110 views

Project Euler Q2 - Sum of even Fibonacci numbers

I'm very new at F#, and am using Project Euler to help me learn. Question #2 kept me going for a while, as my initial attempt at an answer was very slow and inelegant. Then I learnt about Seq.unfold, ...
5
votes
1answer
91 views

Solution to Project Euler problem 5 (LCM of 1 to 20)

I'm an experienced C# developer trying to teach myself F#. I spent a day or 3 reading throught the F# wikibook trying to get to know the syntax and F# fundamentals. As an exercise I'm trying to go ...
4
votes
2answers
98 views

F# code to check whether there are three same digits within a given number

I came across this problem by accident and gave it a go. I think my solution works as it has passed all the unit tests I wrote. Given I just started learning F# a couple of weeks I would love to have ...
5
votes
1answer
76 views

Solving adventcode day 6 puzzle: toggling lights in a grid

I have solved the day 6 adventcode problem: --- Day 6: Probably a Fire Hazard --- Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've ...
7
votes
1answer
102 views

Prime factorization in F#

In the pursuit of learning F#, I have been working through some Project Euler problems. This is my solution for problem 3: ...
4
votes
1answer
62 views

Finding the largest prime factor

As many people will undoubtedly recognise, this is a question in a well known series of problems that I won't name ;) It's been a long time since I've written any F# and I'm not sure I've ever come ...
7
votes
1answer
64 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 ...
4
votes
2answers
82 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 \$...
15
votes
4answers
735 views

Project Euler 6: Difference between sum of squares and square of sum

I've created a (very) simple solution for Project Euler problem 6: Project Euler Problem 6: Sum square difference The sum of the squares of the first ten natural numbers is, $$ 1^2 + 2^2 ...
6
votes
1answer
261 views

Project Euler Problems #1-#5

Since I've been playing with F#, I decided to try my hand at implementing some of the Project Euler problems, and I've been having a blast doing it. (f#-is-fun) So, I'm going to list all the Project ...
9
votes
2answers
320 views

F#zzBuzz: Learning the easy way

So I made a quick programme in F# to do FizzBuzz, I'm trying to learn more languages, so I figured I'd do something functional for a change. (Haskell is also on the list.) FizzBuzz is pretty self-...
3
votes
2answers
57 views

Find unique variants of a product

I am writing a piece of code that returns all the unique variants that a product is available in for an ecommerce app. For example, a shirt product can be available in different colors, sizes, and ...
2
votes
1answer
44 views

Digit Power Sum with BigInteger

This is my 1st F# program so I'm open to any and all criticism on my syntax and the way I approached the problem. Challenge Project Euler 16: Power Digit Sum 2^15 = 32768 and the sum of its digits ...
3
votes
2answers
54 views

Summations and products and factorials oh my

The proper title of this question should be "Summations and products, and factorials oh my!". After getting quite a bit of useful feedback on this question from @mjolka, and a comment, I decided ...
3
votes
1answer
96 views

Trying to do Type-Driven Development in F#

I've been wanting to try out F# for some real world programming so I decided to try rewriting a program that is being used at work. It can be reduced to a few steps: Get report templates. In this ...
2
votes
1answer
53 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 ...
3
votes
1answer
66 views

Renaming video files based on episode title lookup

I'm new to F#, so I've ported an old Python script I have to F#. It scans a directory for files named something like Game.Of.Thrones.S01E02.xvidblahblah.mp4 or <...
1
vote
1answer
49 views

Creating a structured category list in F#

This takes a list of categories and organizes them into a tree-type structure based on their parentId. This code works, but is obviously a little over-complicated. ...