Snippets created by nagat01

  • Minesweeper in 99 lines of code

    This program is written in only 99 lines of actual code and remains enough readability. I used few short-coding technics. 1. no XAML. 2. pre-calculate every useful data for the purpose of eliminating useless states 3. using record type with set property as an alternative of view-model 4. initialize everything in one place. 5. encapsulate all states in one place.

    14 people like this
    Posted: 8 months ago by nagat01

  • Calculate PI number

    PI number calculation based on the wikipedia page(http://en.wikipedia.org/wiki/Pi#cite_note-59). I used Newton's , Machine's and Ramanujan's formula. (updated: line 21: Seq.take => Seq.truncate)

    2 people like this
    Posted: 6 months ago by nagat01

  • Yet another Tennis Kata

    It's a joke one liner implementation of Tennis Kata.Please see this code not seriously.

    1 people like this
    Posted: 6 months ago by nagat01

  • Convert 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 nagat01

  • Bi directional map

    Bi directional map to implement toString and fromString function for descriminated unions.

    3 people like this
    Posted: 5 months ago by nagat01

  • Building 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 nagat01

  • Simple typeclass implementation

    I learned how to implement this by reading this great good project http://code.google.com/p/fsharp-typeclasses/ But I can't understand why the project needs ternary operator. I used binary operator and seems it's okay.

    2 people like this
    Posted: 5 months ago by nagat01

  • Drag move for GUI controls

    This script opens a window with a red rectangle which is moved by dragging. I like writing interactive GUI without MVVM, FRP and Markup language.

    3 people like this
    Posted: 4 months ago by nagat01

  • 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 nagat01

  • TicTacToe(Joinads Example)

    TicTacToe game simulator implemented by using Joinads(http://tomasp.net/blog/joinads-async-prog.aspx). Game logic in this snippet was simplified so nicely by using Joinads. You can run this snippet on Try Joinads (http://tryjoinads.org/).

    3 people like this
    Posted: 3 months ago by nagat01

  • Speech Stackoverflow article automatically

    This snippet automatically speeches text of question,answers and comments in a Stackoverflow article. It requires HtmlAgilityPack(available from Nuget package manager).(Attention: You need reset F# interactive to stop the speech)

    5 people like this
    Posted: 7 days ago by nagat01