This file contains hidden or 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.Runtime.InteropServices | |
| (* C code | |
| union S { | |
| uint32_t u32[4]; | |
| uint64_t u64[2]; | |
| }; | |
| *) |
This file contains hidden or 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.IO | |
| type Terminal<'a> = | |
| | Terminal of string * option<'a> | |
| type CommandResult<'a> = | |
| | Success of 'a | |
| | Failure of exn |
This file contains hidden or 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 BinarySearchTree | |
| type Tree<'a> = | |
| | Empty | |
| | Node of 'a * Tree<'a> * Tree<'a> | |
| let empty<'a> = Tree<'a>.Empty | |
| let singleton key value = Tree.Node ((key, value), empty, empty) |
This file contains hidden or 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
| type HttpStatus = | |
| { Code: string; Message: string } | |
| override self.ToString () = sprintf "%s %s" self.Code self.Message | |
| let httpStatus code message = { Code = code; Message = message } | |
| let httpStatusList =[ | |
| httpStatus "100" "Continue"; | |
| httpStatus "101" "Switching Protocols"; | |
| httpStatus "102" "Processing"; |
This file contains hidden or 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 | |
| type Foo = { Field : int } | |
| let random = Random () | |
| let hasDuplicate keySelector = | |
| let adjacent = Seq.windowed 2 >> Seq.map (function | [| x; y |] -> x, y | _ -> failwith "invalid") | |
| Seq.scan (fun set value -> Set.add (keySelector value) set) Set.empty | |
| >> adjacent | |
| >> Seq.exists (fun (x, y) -> Set.count x = Set.count y) |
This file contains hidden or 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
| \documentclass[$if(fontsize)$$fontsize$,$endif$$if(handout)$handout,$endif$$if(beamer)$ignorenonframetext,$endif$]{$documentclass$} | |
| $if(theme)$ | |
| \usetheme{$theme$} | |
| $endif$ | |
| $if(colortheme)$ | |
| \usecolortheme{$colortheme$} | |
| $endif$ | |
| \usepackage{amssymb,amsmath} | |
| \renewcommand\mathfamilydefault{\rmdefault} | |
| \usepackage{ifxetex,ifluatex} |
This file contains hidden or 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
| moved to https://github.com/kos59125/naturalsort |
This file contains hidden or 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.Collections | |
| open System.Collections.Generic | |
| let cast<'a> : IEnumerator -> IEnumerator<'a> = function | |
| | :? IEnumerator<'a> as e -> e | |
| | e -> | |
| { | |
| new IEnumerator<'a> with | |
| member __.Current = e.Current :?> 'a |
This file contains hidden or 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 Seq = | |
| let takeBy n (source:seq<'a>) = seq { | |
| use e = source.GetEnumerator () | |
| while e.MoveNext () do | |
| yield e.Current | |
| let skip = ref (n - 1) | |
| while !skip > 0 && e.MoveNext () do | |
| decr skip | |
| } |
This file contains hidden or 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
| save_stan_data <- function(data, file, na.replace=NA) { | |
| cat(file=file) | |
| write <- function(...) { | |
| cat(..., file=file, append=TRUE) | |
| } | |
| variables <- if (is.environment(data)) { | |
| ls(envir=data) | |
| } else { | |
| names(data) | |
| } |