Snippets in category Applications
Get Stock Quote Data and Historical Stock Prices from Yahoo Finance
Get Stock Quote Data and Historical Stock Prices from Yahoo Finance.
135 people like this
Posted: 1 years ago by Tuomas HietanenProject Euler #182
The RSA encryption is based on the following procedure: Generate two distinct primes p and q. Compute n=pq and phi=(p-1)(q-1). Find an integer e, 1<e<phi, such that gcd(e,phi)=1. There exist values of e and m such that m^(e) mod n=m. We call messages m for which m^(e) mod n=m unconcealed messages. Choose p=1009 and q=3643. Find the sum of all values of e, so that the number of unconcealed messages for this value of e is at a minimum.
20 people like this
Posted: 1 years ago by Natallie BaikevichPlotting using Chart сontrol
This snippet shows how to plot data on a form using .NET 4.0 Chart control.
28 people like this
Posted: 1 years ago by Dmitry SoshnikovDisposable computation builder
Computation builder that provides easy way of constructing IDisposable objects. It supports elegant composition of disposable objects using 'do!' which can be used for example when working with 'IObservable' type.
27 people like this
Posted: 1 years ago by Tomas PetricekParse HTTP chunked response
Code to parse HTTP chunked response, to use as a client to a Comet server who uses chunked encoding to transfer real time notification data
1 people like this
Posted: 1 years ago by Ankur DhamaObservableObject
The ObservableObject type implements the INotifyPropertyChanged interface used in WPF and Silverlight to notify on changes to properties that are bound to a control. Specify property names type safely using F# Quotations, i.e. <@ this.PropertyName @> when invoking the NotifyPropertyChanged method. If you are following the MVVM pattern then your View Model class can inherit from the ObservableObject type.
45 people like this
Posted: 1 years ago by Phillip TrelfordObservable.Subject
The Subject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the type of the same name in the Reactive Extensions (Rx) library.
13 people like this
Posted: 1 years ago by Phillip TrelfordFarey Sequence
Return a sequence that contains the numerators and denominators as tuples for Farey Sequence n.
1 people like this
Posted: 1 years ago by Graham SpiersJaro-Winkler in F#
Jaro-Winkler is a fast and effective name matching algorithm. For more info see "A Comparison of String Distance Metrics for Name-Matching Tasks" http://www.isi.edu/info-agents/workshops/ijcai03/papers/Cohen-p.pdf or the Wikipedia article http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance
21 people like this
Posted: 1 years ago by Rick MinerichScheme interpreter in F#
A small Scheme interpreter using Higher Order Abstract Syntax (HOAS) encoding for terms. The essence of the technique is to use F# (meta-level) functions to encode Scheme (object-level) functions and other binding constructs, thus avoiding the need for representing variables, bindings, explicit substitution and dealing with shadowing.
17 people like this
Posted: 1 years ago by Anton TayanovskyyF# googelsearch
A google search automation.
19 people like this
Posted: 1 years ago by Chief Inspector ClouseauGraham scal algorithm for finding the convex hull of a sequence of 2D points
finds the points lying on the convex hull of the given set of points and returns those points in clockwise direction, starting at the point with minimum y-value Remarks: it's a more or less direct implementation of the algorithm named after Ronald Graham that is explained on http://en.wikipedia.org/wiki/Graham_scan you can switch the definition Point for a proper type of your liking - e.g. System.Drawing.Point
30 people like this
Posted: 1 years ago by Carsten KönigQR-decomoposition of a square-matrix using the Gram-Schmidt method
shows a simple implementation of a vector and matrix type together with a QR-decomposition using the Gram-Schmidt method. The algorithms themselfes are rather easy but I think the implementation of the types and the computations using recursive techniques might be interessting
2 people like this
Posted: 1 years ago by Carsten KönigYahoo Historical Quote Implementation
F# module to return historical EOD: open | high |low | close | volume quotes from Yahoo. Single day requests only. DataContract provided on the result record for easy serialization.
10 people like this
Posted: 1 years ago by akaPhenomLexer
Hand-written efficient JavaScript lexer from the IronJS project https://github.com/fholm/IronJS
16 people like this
Posted: 1 years ago by fholmCompiler Regression in VS2010-SP1
Compiler regression in VS2010-SP1 ?
21 people like this
Posted: 1 years ago by fholmMD5 hash
A function that computes an MD5 hash from a block of bytes. MD5 isn't cryptographically secure, but it's a handy way of condensing a block of data into a short string.
14 people like this
Posted: 1 years ago by Tim RobinsonBlack Scholes Option Pricing
The code shows simple implementation of blackscholes algorithm.
2 people like this
Posted: 1 years ago by Kishor AherHistorical Volatility
The code snippet is capable of calculating historical volatility using Close Price, High Low Price and Close High Low Price methods. Simply provide symbol, start date and end date of the specific volatility method and it extracts the market data from the yahoo service and calculated the volatility.
3 people like this
Posted: 1 years ago by Kishor AherWeb Crawler
This snippet features an F# Web crawler that i'm already using in 2 applications (slightly modified). It's based on a scalable network of communicating agents that follow URLs extracted from HTML pages until reaching the specified limit.
20 people like this
Posted: 1 years ago by Taha HachanaType-a-head search tree for strings
This is a search tree for strings I've built for work to back fast type-a-head for AJAX forms, it could be made million times more space efficient but there was no real need for it so.
3 people like this
Posted: 1 years ago by fholmCSV 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 SchusterHow to write a financial contract
Implements the theory from 'How to write a financial contract' by S.L Peyton Jones and J-M Eber
7 people like this
Posted: 1 years ago by Ademar GonzalezResource cleanup event combinator
Declares an event combinator 'Event.using' that automatically releases resources allocated by a previous event occurence. Each event occurence creates a value using a function specified by the user and automatically calls 'Dispose' when generating a new value.
2 people like this
Posted: 1 years ago by Tomas Petricekstore 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 TangA failed attempt at evaluating sequence items in terms of a try-with block
A broken code example demonstrating how it's you can't catch a single throwing enumeration and continue with F#'s IEnumerable.
2 people like this
Posted: 1 years ago by Rick MinerichSpreadsheet
Spreadsheet script runnable inside http://tryfsharp.org includes a custom DataGrid and a parser for simple formulas e.g.: =1+1 =SUM(A1,A2) Add your own functions to the evaluate function. For a more comprehensive implementation check out http://cellz.codeplex.com
2 people like this
Posted: 1 years ago by Phillip TrelfordAsynchronous Controller Helper
The snippet declares a helper for creating asynchronous controllers for ASP.NET MVC 3. It declares a new base class for asynchronous actions that exposes a computation builder for writing actions using F# asynchronous workflows.
7 people like this
Posted: 1 years ago by Tomas Petricekexec with redirected io as sequences
Since F# is my new scripting language, I needed something like Perl's exec but with sequences for Std In and Out.
5 people like this
Posted: 1 years ago by Tony LeeThe repmin problem
The repmin problem is to replace all elements of a tree of numbers by the minimum element, making only a single pass over the original tree. Repmin is a very ingenious example of Circular Programming.
1 people like this
Posted: 1 years ago by Nick PalladinosTimestamp with timezone (YYYYMMDDhhmmssffff+zzzz)
Timestamp: Time format in ISO 8601 with timezone. YYYYMMDDhhmmssffff+zzzz For example 2011-05-17 19:01:10.000 -0200 would be: 20110517190110000-0200
2 people like this
Posted: 1 years ago by Tuomas HietanenF# Quotations with INotifyPropertyChanged
ViewModelBase for F# users who want to use it in WPF / Silverlight
6 people like this
Posted: 1 years ago by FahadCalculator
Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.
0 people like this
Posted: 12 months ago by Phillip TrelfordCalculator
Simple Silverlight Calculator UI interactive sample runnable inside http://tryfsharp.org.
0 people like this
Posted: 12 months ago by Phillip TrelfordFormula Calculator
Simple formula calculator including dynamic unit of measure support. Run as a script in Try F#, and try formula with units like 3m * 3m.
0 people like this
Posted: 12 months ago by Phillip TrelfordCreate Open XML Word document
Create Open XML Word document using the open XML SDK
Create Open XML Word document
Create Open XML Word document using the open XML SDK
3 people like this
Posted: 11 months ago by Piet AmersfoortCreate Open XML Spreadsheet
Create Open XML Spreadsheet using the open XML SDK
1 people like this
Posted: 11 months ago by Piet AmersfoortA fun-ny WPF DataTemplate DSL
Parts of a little DSL to create WPF DataTemplate's in F#. Don't even want to think about the length of a corresponding C#. The F# code corresponds 1-to-1 to the visual tree constructed for the template.
5 people like this
Posted: 11 months ago by Cetin SertCreate a Open Xml word document from a string array
Create a Open Xml word document from a string array. In this snippet I did not reference the Open Xml SDK
1 people like this
Posted: 11 months ago by Piet AmersfoortSimple F# ViewModel for Silverlight MVVM
Silverlight default architecture is Model-View-ViewModel. This code gives full design time support for Microsoft Expression Blend. The F# ViewModel is seen as strongly typed data source in the Blend UI. There are two properties binded to the view: HiLabel (OneWay data binding) and MyName (TwoWay data binding). ViewModel implements the INotifyPropertyChanged to support the binding. The view project (HelloApp) is made with Blend (by designers) and it is Silverlight 5.0 project. The view codebehind is c# file and it has only this.DataContext -assignment. The viewmodel project (HelloApp.ViewModel) is F# Silverlight 4.0 library. It is made with VS2010 and F# (by developers). It contains the logical functionality of the current view.
4 people like this
Posted: 11 months ago by Tuomas HietanenThrottling agent
Agent that can be used for controlling the number of concurrently executing asynchronous workflows. The agent runs a specified number of operations concurrently and queues remaining pending requests. The queued work items are started as soon as one of the previous items completes.
9 people like this
Posted: 11 months ago by Tomas Petricek
ReplaySubject
The ReplaySubject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the class of the same name in the Reactive Extensions (Rx) library with a replay buffer of a specified size .
1 people like this
Posted: 11 months ago by Phillip TrelfordAsynchronous Workflow Controller
The snippet overrides default AsyncControllerActionInvoker so F# async workflows can be used for ASP.NET MVC 3. It declares a new base class for asynchronous controller. Controller method has to have return type Async<ActionResult>.
3 people like this
Posted: 11 months ago by Dmitry MorozovSilverlight asynchronous WebService call with UI-thread syncronization dispatcher
You can use this code to make a async WebRequest from Silverlight to update ViewModel.
4 people like this
Posted: 11 months ago by Tuomas HietanenReading a collection of records from database
This snippet can be used to read all records from a given table and expose them as an IEnumerable<T> (seq)
3 people like this
Posted: 11 months ago by Eduardo ClaudioCreate Open XML Spreadsheet with data
Create a Open Xml spreadsheet fromxml. In this snippet I did not reference the Open Xml SDK
3 people like this
Posted: 11 months ago by Piet AmersfoortIncremental auto-completion
Returns subsets of strings which match a specified prefix. The prefix is built incrementally by repeatedly calling a search function.
1 people like this
Posted: 11 months ago by Johann DeneuxDiscount/Zero Curve Construction
A simplistic discount curve bootstrapping process
10 people like this
Posted: 11 months ago by Wayne BradneyTetris
Playable Tetris mini-game. Use arrow keys to move left and right and up to rotate, down to drop. Try it out in the browser on TryFSharp.org
10 people like this
Posted: 10 months ago by Phillip TrelfordFunctional Unparsing SQL
A combinator based DSL for composing type-safe parameterized sql queries. Inspired by Olivier Danvy's "Functional Unparsing" paper.
8 people like this
Posted: 10 months ago by Nick PalladinosStill Mouse Click Event
Detects a mouse down then up event without a move.
3 people like this
Posted: 10 months ago by Phillip TrelfordStill Mouse Click Event Using Scan
Detects a mouse down then up event without a move.
1 people like this
Posted: 10 months ago by Zach BrayWPF/Silverlight Value Converter
Example of a WPF/Silverlight Value Converter base class and concrete implementation.
5 people like this
Posted: 10 months ago by Tao Liu and Daniel MohlWPF/Silverlight Attached Property
Example of a WPF/Silverlight Attached Property (AP). This is a port of a C# AP implementation that can be found at http://www.silverlightshow.net/items/Attached-Properties-in-Silverlight.aspx.
2 people like this
Posted: 10 months ago by Daniel MohlExtensions for HTTP servers
This snippet extends several types from the System.Net namespace. It provides an easy to use API for creating asynchronous (as well as synchronous) HTTP servers using F# asynchronous workflows.
3 people like this
Posted: 10 months ago by Tomas PetricekSynchronous, event-based and asynchronous HTTP proxy
This snippet shows the implementation of three HTTP proxy servers in F#. The first is written using simple synchronous style (that isn't scalable). The second version uses event-based approach in the Node.js style, but is difficult to write. The third version uses F# async workflows and is both scalable and easy to write.
5 people like this
Posted: 10 months ago by Tomas PetricekAsynchronous HTTP proxy with chunking and caching
This snippet shows two improvements to asynchronous HTTP proxy from: http://fssnip.net/6e. First extension is to process page in chunks (instead of downloading the entire content first). The second extension is to use simple agent-based in-memory cache for previously visited pages.
5 people like this
Posted: 10 months ago by Tomas PetricekNorvig's Spelling Corrector
A line-by-line translation of Norvig's original Python code. An attempt to view F# as a "typed" Python.
4 people like this
Posted: 10 months ago by Nick PalladinosGet COM instances from Running Object Table
Type extensions for System.Activator which enable the retrieval of COM instances from the Running Object Table.
1 people like this
Posted: 10 months ago by Huw SimpsonAsyncSeq - Introduction and Crawler
This snippet demonstrates programming using asynchronous sequences. It contains (hidden) implementation of AsyncSeq type and combinators for working with it. More importantly, it demonstrates how to use asynchronous sequences to implement a simple sequential on-demand crawler.
8 people like this
Posted: 9 months ago by Tomas PetricekGrowing Tree Algorithm for Maze Generation
There are several maze creation algorithms (http://www.astrolog.org/labyrnth/algrithm.htm). The interesting point about Growing Tree one is that it turns into the others (for example, Recursive Backtracker and Prim's algo) when we choose the next step in different ways. Check it with tryfsharp.org.
8 people like this
Posted: 8 months ago by Natallie BaikevichWPF / SilverLight Converter II
version 1 is http://fssnip.net/62. This new version support convert from any existing function to a converter function by using composition and pipeline. The convert function is to make the function signature agree to the IValueConverter interface. You can add new functions in the FunctionLibrary module and reuse the class definition to reduce the coding effort. The first sample is to show how to make the converter pipeline work, the second one is a debugger converter used to debug the data binding problem.
74 people like this
Posted: 8 months ago by Tao LiuCreating observable using Async.StartDisposable
Implements a simple Async.StartDisposable extension that can be used to easily create IObservable values from F# asynchronous workflows. The method starts an asynchronous workflow and returns IDisposable that cancels the workflow when disposed.
4 people like this
Posted: 8 months ago by Tomas PetricekSliding window for Observable
Implements the Observable.windowed function that creates an observable returning a sliding window. The function is an observable version of Seq.observable. The implementation uses a simple F# agent that keeps partial windows and sends them to an observer.
3 people like this
Posted: 8 months ago by Tomas PetricekSHA256
Calculates sha256 of the files passed in on the command line. Usage: fsi sha256.fsx downloadedFile.zip
1 people like this
Posted: 7 months ago by Tony LeeSimple Reactive Extensions Example
Subject is a class that implements both IObservable<'T> and IObserver<'T>
5 people like this
Posted: 6 months ago by Tuomas HietanenCaching agent
Agent that keeps a cache of web pages that were downloaded previously. The agent handles messages to add and get data as well as message to clear the cache.
2 people like this
Posted: 6 months ago by Tomas PetricekConvert the number of indentation spaces in a sourcecode.
This small script converts continuous 4 spaces to 2 spaces by using Regex. It gets the source code from a clip board text and save it to clip board. Since this program doesn't parse the source code, conversion is not perfect. But writing script which interacts with clipboard is so easy, you can automate your trivial coding work with a small effort. Using F#interactive with Clipboard is my favorite way of meta-programming.
1 people like this
Posted: 6 months ago by nagat01LINQ to SQLite
Simplest possible sample code for accessing an in-process SQLite database file using LINQ The code does not use a dbml file for the mapping, but an attribute enriched type. (F# script, .Net 4.0, F# 2.0)
6 people like this
Posted: 6 months ago by Dirk DevriendtBuilding a WPF application in functional way
I started to write pure F# + WPF application in about half a year ago. Today, I found a good way to compose WPF controls with dependent values. It's only writing a dependency object type as a class and give it to constructors of GUI controls. In this snippet "Volume","ColorVolume" and "ShapeContainer" has no properties. But works as a View which represents internal Model and allows users to change internal data. You only need calling a constructor of them. It means that you can compose GUI controls and it's functionality as a immutable data structure. (Update 2011/12/02 8:33:00(UTC+09:00) : Removed some user defined operators and renamed a type similar to DependencyObject in this snippet Reactor to SharedValue.) (Update 2011/12/02 9:04:01(UTC+09:00) : renamed some variables..)
6 people like this
Posted: 5 months ago by nagat01Observable Async Subject
Simple Async Observable Subject<'T> based on MailboxProcessor. Type declaration is more ML like, but the idea is represented in a simple way!
4 people like this
Posted: 5 months ago by FahadEnum -> MVC3 SelectList
Converts an Enum to a Selectlist which can be used by a @Html.DropDownList
10 people like this
Posted: 4 months ago by christophdLoading .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 nagat01Send HTTP POST request
The snippet shows how to send HTTP POST request to a web page and download the generated HTML result. The POST data is encoded as a byte array and written to the request stream of HttpWebRequest.
2 people like this
Posted: 3 months ago by Tomas PetricekStackOverflowCrawler
Tries to find the best technologies from stackoverflow. Don't use too wide tags (with many thousand request) or firewall will block you!
Pong
Pong video game runnable inside TryFSharp.org. Player 1 keys 'Q' - up, 'A' - down. Player 2 keys 'P' - up, 'L' - down.
5 people like this
Posted: 3 months ago by Phillip TrelfordPeter Henderson's picture language from SICP
An implementation of (part of) Peter Henderson's picture language from the SICP book.
4 people like this
Posted: 3 months ago by Jonas AvelinWrapPanel
Positions child elements in sequential position from left to right, breaking content to the next line at the edge of the containing box. Tryable at http://tryfsharp.org
3 people like this
Posted: 2 months ago by Phillip TrelfordWPF Command in F#
demonstrate how to use object expression to create a WPF/Silverlight command.
17 people like this
Posted: 2 months ago by Tao LiuSIngle Life Annuity
A single life annuity function in F# including supporting functions such as probability of survival, pure endowment and discounted interest rate calculation.
0 people like this
Posted: 1 months ago by Kevin RocheSingle Life Annuity
A single life annuity function in F# including supporting functions such as probability of survival, pure endowment and discounted interest rate calculation. Should add that I'd be interested in making this more "functional"; at the moment it seems like a chunk of procedural code to me - any advice would be very welcome.
3 people like this
Posted: 1 months ago by Kevin RocheAsync HTTP server
Creating an asynchronous HTTP Server in F#.
6 people like this
Posted: 1 months ago by Julian KayF# 3.0 - EntityFramework Type Provider usage with Northwind DB
A small sample how to use F# 3.0 Entity Framework (EF) Type Provider. Visual Studio 11 Beta (and Northwind sample database) needed.
3 people like this
Posted: 29 days ago by Tuomas Hietanen