Snippets in category Input and Output
Hello world (F#)
Classical "Hello world" example that prints a message to the console output. This version uses F# printfn function to do the printing.
131 people like this
Posted: 1 years ago by Tomas PetricekHello world (.NET)
Classical "Hello world" example that prints a message to the console output. This version uses .NET Console.WriteLine method to do the printing.
23 people like this
Posted: 1 years ago by Tomas PetricekFriendly date formatting
Generates a friendly string describing a date relatively to the current date and time. The function returns strings like "2 secs ago", "yesterday" or "3 years ago".
26 people like this
Posted: 1 years ago by Tomas Petricek'use' Bindings
Show's how to use F# 'use' key word to dispose a resource when it passes out of scope.
24 people like this
Posted: 1 years ago by Robert PickeringNice formatting of type names
Add extension to System.Type that returns the name of type including generic arguments in a nice readable format. It returns only short names of generic type and type arguments.
13 people like this
Posted: 1 years ago by Tomas Petricekwarning check
kprintf for logging
Handy *printf feature: use kprintf to prepend datetime to formatted message
45 people like this
Posted: 1 years ago by Vladimir MatveevConditional printf
Disable printf based on some condition
26 people like this
Posted: 1 years ago by Laurenttest
megaton/cluster.fs
very simple password gen
asd
Working with paths
Concatenating paths shouldn't be done just using string concatenation, because the directory separator may differ on various platforms. This snippet shows a simple custom operator for working with paths.
9 people like this
Posted: 1 years ago by Tomas PetricekAsynchronous sequences
An asynchronous sequence is similar to the seq<T> type, but the elements of the sequence are generated asynchronously without blocking the caller as in Async<T>. This snippet declares asynchronous sequence and uses it to compare two files in 1k blocks.
36 people like this
Posted: 1 years ago by Tomas PetricekEnumerableStream
EnumerableStream
A lazy enumerable/stream of bytes.
8 people like this
Posted: 1 years ago by Ryan RileyAsync hashing
Async memory or file hashing
8 people like this
Posted: 1 years ago by Mauricio SchefferCreating charts in F#
Exiting cleanly
Demonstrates how to run a function when the user presses Ctrl+C, closes the console window, or logs off.
29 people like this
Posted: 1 years ago by Tim RobinsonA Simple F# QuadTree
Euler 1 as a Computation Expression
Project Euler 1 - While Loop
Abstract Console.ReadLine as an infinite sequence
Abstracts console input as an infinite sequence of strings
7 people like this
Posted: 1 years ago by fholmtest version
Dumping record type sequence to file
Easy dump of record type sequence to file
17 people like this
Posted: 1 years ago by Chief Inspector Clouseauannuity
Restartable File.ReadLines
.Net 4.0 added File.ReadLines to view a file as a sequence, but the sequence can only be read once. A simple wrapper with seq{yield!} fixes that.
32 people like this
Posted: 1 years ago by Tony LeePretty Print Source Code Errors
A snippet that allows you to pretty print source code errors
13 people like this
Posted: 1 years ago by fholmTesting inserting new snippet
Hello
LiteMedia_Example1_BasicSyntax
Unit List
CSV reader
I've modified the CSV sample from Expert F# to my needs. I don't wann be forced to use the csv schema as defined by column rows. Therefore I've done two major modifications. 1. remove the permutation 2. added a new column name option to the ColumnAttribute 3. added a name to csv index mapping So basically you now have 3 options. 1. Don't annotate your record at all and use it as POCO. The order of the record fields is mapped directly to the order in the csv. UPDATE: I don't recommend this any more. As of the writing of this snippet I wasn't aware of the fact, that field order isn't guaranted by the reflection mechanism. 2. Use the index option of the ColumnAttribute. Same as before. 3. Use the name option. This is what I've looked for. I've to deal with tons of csv that has more columns I'm interested in. Have a look at the sample usage below. I've moved the type conversion out of the CsvReader class in order to be easyly expandable with custom type conversation (i.e. for combined column values - denormalized data)
4 people like this
Posted: 1 years ago by Rainer SchusterCSV writer
A simple CSV writer implementation as two type extensions for the Seq module. Use it with Records, Classes and Tuples. Have a look at the modified CSV reader sample from Don Symes Expert F# too http://fssnip.net/3T in order to advance this snippet using the ColumnAttribute
3 people like this
Posted: 1 years ago by Rainer SchusterEvaluation Strategies
Prime Numbers
Binary Literals
Immunity
Awful Space adding code
Pipelining example
store yahoo quotes in kdb
This snippet will download the constituents from ftse, stoxx50e,dji,hsi,gspc and store quotes beginning from 1981 into kdb. To get this to work you need to download kpnet from http://kpnet.codeplex.com/ and kdb.
1 people like this
Posted: 1 years ago by Kim Tangsscanf - parsing with format strings
A more complete version of sscanf, as proposed on stackoverflow by kvb: http://stackoverflow.com/questions/2415705/read-from-console-in-f
7 people like this
Posted: 1 years ago by Wolfgang Meyertest
async
quest
quest
questflow prototype
quest
quest
quest
Async File Crawl
Async File Crawl
6 people like this
Posted: 11 months ago by fholmAsync web request from Silverlight
Simple Exp
Simple Exp
String explode and implode functions
funscript
Parallel Seq windows eventlogs
Odd error running a benchmark on Mono
Tuple Performance
Tuple Performance
Project Euler #4
test1
ICFP2011
test
Interface workaround for circular dependency problem
Interface workaround for circular dependency problem
3 people like this
Posted: 10 months ago by fholmAgent Based Scheduler
An agent based scheduler, can be sent a single schedule message (ScheduleOnce) and multiple schedule message (Schedule). The schedule messages comprise of a function to receive the message, the message, an initial TimeSpan before the message is scheduled, and another timespan for the schedule repeat. Check out my blog below for more details: http://bit.ly/mK4prb
4 people like this
Posted: 10 months ago by 7sharp9Iteratee
An iteratee based on https://john-millikin.com/software/enumerator/ and http://okmij.org/ftp/Haskell/Iteratee/IterateeIO-talk-notes.pdf
6 people like this
Posted: 10 months ago by Ryan RileyTiny IO Monad
Haskell-style IO in F#.
6 people like this
Posted: 10 months ago by igetasolver
one to nine puzzle
Draw rectangle in TryFSharp.org
Split string input on a function
ByteString
An initial attempt at creating a ByteString type based on the Haskell version.
1 people like this
Posted: 10 months ago by Ryan RileyComplex 1 - Intro
Complex 2 - First Operator
Complex 1 - Intro
Complex 3 - Operators
Complex 4 - Conjugate
Complex 5 - Polar Form
Complex 6 - Roots
Complex 7 - Chapter 2 Problems
Complex 8 - Graphics Intro
Complex 9 - Draw Sets
Complex 10 - Draw Mandelbrot
IDisposable dispose helper
Nontrivial Gotos
11 - Mouse Handlers
A little nicer
13 - Trig Functions Display
IterateeCPS
An iteratee that uses continuation-passing style as an optimization. There is no more discriminated union, and the signature should feel familiar to those using Async.StartWithContinuations.
5 people like this
Posted: 9 months ago by Ryan RileyStructPerfTest
equalstest2
14 - Function Sets Display
foo
sqr
pushkin tree
Pushkin tree v 2.0
15 - Parameterized Paths
16 - Integration
JaroWinkler in F#, and more
DNS, Async
Jaro-Winkler in F#, Extended
Wrong use of Call/CC for Async
How does Observable.Window behave?
Find Files Bigger Than
netty
Pack consecutive duplicates of list elements into sublists
Stack Calc Monad
Pipeline vs composition performance
Logging
Tree traverse & compare
Test
RateLimitedMessage
Incorrect implementation, correct theory of cracking
Async Wait Operation
Assembly signature generation for MSBuild
Times Table game
Simple times table console based game.
2 people like this
Posted: 7 months ago by Phillip Trelfordfloat double math
Auto-Properties
async clip
async clip
pipeline clip
Compute CC.Net build statistics
Written against CruiseControl.NET v1.5. Queries a CruiseControl.NET server for a project list and then computes min, max, average, and standard deviation of the build durations based on the statistics.csv CC.NET maintains.
3 people like this
Posted: 6 months ago by Matt WilsonAgent Registry
Dont know if it's right
Human Date
Datetime Readable for Humans, Ported from Clojure https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/utils/utils.clj
23 people like this
Posted: 6 months ago by christophdtest code for the serializer
worley-noise
better worley noise
failed perlin noise attempt
perlin noise
foo
scheduler
LandOfF
vortex level 0 over the wire
F# syntax for creating HTML/XML
Forking console output to a string
Higher order function 'withOutStr' to fork console output to a string. The function temporarily redirects Console.Out to a custom TextWriter
4 people like this
Posted: 5 months ago by Jonas AvelinCalculate left margins
Possible bug
Temp
Risk Assignment in F#
Loading .fs files
This script facilitates to load all the .fs files in the specified F# project in correct compilation order.
3 people like this
Posted: 4 months ago by nagat01Fake ternary operator for creating arrows
Circular Buffer
A Circular, or Ring, Buffer that flattens incoming arrays and allows consumers to take arbitrary-sized chunks. Improvements and suggestions welcome. Fork my gist at https://gist.github.com/1648579.
4 people like this
Posted: 3 months ago by Ryan Rileyfibbonaci
Lab1
Retail Domain
deserialising php's serialise
generating partions of a number
foo
Private Implementation Inheritance without boilerplate
How to avoid delegation boilerplate in inhertance heavy OOP code while maintaining proper accessibility like seen here https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/seq.fs#L82 and mentioned in Expert F# 2.0 "Using Partially Implemented Types via Implementation Inheritance " Uses auto-properties that only work with F# 3.0
7 people like this
Posted: 2 months ago by Associat0rPimpl
Pimpl ctor ref prop
Sim
Poll a file until it is quiet
One of the problems with using FileSystemWatcher to detect new files and process them is that it tells you when the file starts being created, not when it finishes. Use this little function to poll the file until it stops being written to.
2 people like this
Posted: 2 months ago by Kit Easonarcanum #1
Static scope for immutable variables
Darkus April-2012 contest entry
Building Strings
When sprintf and String.concat is either too slow or not really what is needed, one can use System.Text.StringBuilder. This snippet makes working with StringBuilder much more convenient and the resulting code more succint.
1 people like this
Posted: 1 months ago by Bent RasmussenComposing Queries in F#
Aggregate Agent
Huy123
derived ctor fail
Dojo chart example for Try F#