This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BishopAttacks(sq,occ) | |
(MagicAttacks[ | |
BOffset[(sq)] + | |
(((BMagicMask[(sq)] & (occ)) * BMagic[(sq)]) >> BShift[(sq)]) | |
]) | |
#define RookAttacks(sq,occ) | |
(MagicAttacks[ | |
ROffset[(sq)] + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BishopAttacks(sq,occ) | |
(MagicAttacks[ | |
BOffset[(sq)] + | |
(((BMagicMask[(sq)] & (occ)) * BMagic[(sq)]) >> BShift[(sq)]) | |
]) | |
#define RookAttacks(sq,occ) | |
(MagicAttacks[ | |
ROffset[(sq)] + | |
(((RMagicMask[(sq)] & (occ)) * RMagic[(sq)]) >> RShift[(sq)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bd where | |
import Array | |
import Char | |
import Utils | |
-- types | |
data Pc=Pc {co::Co, pcType::PcType} deriving Eq | |
data PcType = Ro | Ni | Bi | | |
Ki | Qu | Pa deriving (Eq,Enum) | |
data Co = Bl | Wh deriving (Eq,Enum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm trying to translate C# code to F# for my training | |
// http://www.fincher.org/tips/Languages/csharp.shtml | |
open System | |
open System.IO | |
// A. Hello world program | |
let helloWorld = Console.WriteLine "Hello World!" | |
// C. Read and print an entire file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: Test2's destructor does not work | |
open System | |
open System.IO | |
open System.Net | |
type Test2() = | |
// static variable | |
[<DefaultValue>] | |
static val mutable private i:int | |
// static constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
My training.Translating C# code to F#. | |
http://www.fincher.org/tips/Languages/csharp.shtml | |
*) | |
open System | |
open System.IO | |
open System.Net | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Text.RegularExpressions | |
// http://msdn.microsoft.com/en-us/library/ms228595(v=vs.80).aspx#Y300 | |
let regexIsMatchSample lines pattern = | |
// for line in | |
List.iteri(fun i line -> | |
if Regex.IsMatch(line,pattern,RegexOptions.IgnoreCase) then | |
printfn"%3d : %s" i line) lines | |
regexIsMatchSample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ with RegexOptions.Multiline does not work for verbatim string's end of lines | |
open System | |
open System.Text.RegularExpressions | |
let matchEndOfLineWord = | |
let regex = new Regex("\w+$",RegexOptions.Multiline) | |
regex.Matches("Yuki Nagato\nHaruhi Suzumiy\nMikuru Asahina") | |
|>printfn"%A" | |
regex.Matches(@"Kyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
http://msdn.microsoft.com/en-us/library/30wbz966(v=vs.71).aspx#Y470 | |
Match : finds first occurrence | |
Match.Success : is match succeed? | |
Match.Groups : collection of captured groups | |
Matches : store every non-overlapping occurrences to Item | |
Matches.Item : indexed property of mathed string | |
*) | |
open System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://codezine.jp/article/detail/5696?p=5 | |
// I don't own any right for this program. | |
// Read above url for read original program. | |
// You can escape double quote by writing it | |
// twice in verbatim string literal. | |
// [^""]* : match to double quote any times | |
// \> : unknown | |
// \< : | |
// (?<title>.*) : match to any character any times | |
// and this group is named as "title" |
OlderNewer