F# is a succinct, expressive, and efficient functional and object-oriented language for .NET
3
votes
0answers
87 views
Thousands of GET requests for brute-force authentication attempts
I am applying a brute force to discover 123456 passwords in a given site (I am not going to say which one, of course).
The html gets a ...
6
votes
1answer
82 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 ...
3
votes
2answers
171 views
Event sourcing using functional programming
Is this a satisfactory implementation of event sourcing using functional programming?
...
1
vote
0answers
36 views
Learning F# - Run Lenght Encoding / composition of lists [closed]
My first attempt to code some stuff in F# resulted in this Run Lenght Encoding function.
I want to compose the result list but I cannot append tuples to the result list at the end using ::, but only ...
4
votes
2answers
132 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 "...
2
votes
0answers
99 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 ...
4
votes
0answers
114 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
0answers
47 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 ...
4
votes
0answers
41 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
74 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
57 views
5
votes
3answers
72 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 ...
6
votes
1answer
100 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
140 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 ...
7
votes
2answers
217 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 ...
12
votes
1answer
276 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
109 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 ...
7
votes
2answers
91 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?
...
3
votes
1answer
75 views
3
votes
2answers
108 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.
...
5
votes
1answer
90 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
64 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. ...
5
votes
1answer
114 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.
...
3
votes
1answer
86 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 ...
5
votes
1answer
178 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 ...
4
votes
3answers
73 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 ...
2
votes
2answers
121 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
141 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
34 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
84 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
240 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
152 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
88 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:
...
11
votes
2answers
169 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 ...
1
vote
0answers
38 views
Simple Agent in F#
I wrote a simple agent system based on the agent type from Akka. It allows you to encapsulate a mutable state in a thread safe manner for use cases where mutation would be most convenient (like for ...
4
votes
1answer
70 views
Directory listing, sorting and filtering in F#
Here is my first try at F#. My only functional experience is from JS.
This program takes a path as an argument and presents the user with numbered subdirs in that path. The user then selects one of ...
12
votes
3answers
648 views
Return total balance from unsorted purchase items that may have specials
This is in reference to the following kata:
...
3
votes
1answer
57 views
F# Simple Tree evaluation
I'm currently trying to learn the idiomatic way to write F# code. The code simulates a basic calculator with only binary plus, minus and unary minus.
I'd like to know if there is a better way to ...
6
votes
1answer
87 views
Unit test for allowable checkers moves
Is pattern matching within a unit test a code smell?
Do I really need to throw an exception just for my test to fail if the function under test receives invalid arguments (i.e. not Succeeded case ...
1
vote
1answer
62 views
Idiomatic F# unit test using xunit and unquote
I'm writing some unit tests for testing C# code but I'm using F# and Unquote for the first time for the unit tests and would like some input as to how I might make the tests more 'f-sharpier' to take ...
7
votes
2answers
97 views
Checkers moves using union types
How do I refactor common code with different union types?
I'm still struggling with refactoring F# code with different types but same behavior.
I have the following function that I would like to ...
8
votes
1answer
92 views
TCPListener server to discover clients on a network
I am currently writing a program to sync files (music, photos, etc) from my PC to an Android device. In order to do this, I have 2 application: one that is running on my PC, and one that shall be ...
6
votes
1answer
115 views
Card combination finder in F#
I have been adding and tinkering a bit with the code from my Baloot tally finder. I updated the code a bit and factored a new things, but for this post I am trying different stuff: to detect whether ...
5
votes
1answer
59 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
95 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
90 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
167 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 ...
6
votes
1answer
63 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
68 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
184 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 ...